会社のネットワーク上のWCFサービスにアクセスしようとしています。私はプロキシとsvcutilによって生成された設定ファイルを使用しています。コードは次のようになります。もう1つの「既存の接続がリモートホストによって強制的に閉じられました」問題
using (Client client = new Client())
{
client.Open();
client.DoStuff();
}
クライアントは、それがSystem.ServiceModel.ClientBase由来と契約インターフェイスを実装していますつまり、生成されたプロキシコードでクライアントクラスです。
はまた、設定ファイルは次のようになります。
<configuration>
<system.serviceModel>
<client>
<endpoint address="net.tcp://Address"
binding="netTcpBinding"
bindingConfiguration="Config"
contract="Namespace.Contract"
name="name">
<identity>
<servicePrincipalName value="Host" />
</identity>
</endpoint>
</client>
<bindings>
<netTcpBinding>
<binding name="Config"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
私は例外を取得コードがclient.Openに達する毎に、「既存の接続はリモートホストに強制的に切断されました」()。本当に気になるのは、別のコンピュータから試してみると、例外はありません。そして、その上に、設定ファイルなしに変更されたトランスポートセキュリティを持っていた、と最初のマシンとサーバ上で、それは
だのに対し、それはまだ動作するコンピュータは<security mode="Transport">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
と、古い設定ファイルを持っています
<security mode="None">
<transport clientCredentialType="None" />
</security>
これはどうしてですか?私はこの例外に関して他にも数多くの質問を読んだことがありますが、誰も私の問題に似ていないようです。
SOLVED!私は間違った場所にセキュリティオプションを設定しました。 ServiceHostでサービスが自己ホストされていて、Securityプロパティが設定されていないため、None以外の何かにデフォルト設定されていました。
ありがとう、私はIISではなくServiceHostでホストしましたが、私の問題は似ていました。 – ggPeti