Note that there are some explanatory texts on larger screens.

plurals
  1. POJust another "An existing connection was forcibly closed by the remote host" issue
    primarykey
    data
    text
    <p>I'm trying to access a WCF service on a company network. I'm using the proxy and config file generated by svcutil. The code looks like this:</p> <pre><code>using (Client client = new Client()) { client.Open(); client.DoStuff(); } </code></pre> <p>Client is the client class in the generated proxy code, meaning it's derived from System.ServiceModel.ClientBase and implements the Contract interface.</p> <p>And the config file looks like this:</p> <pre><code>&lt;configuration&gt; &lt;system.serviceModel&gt; &lt;client&gt; &lt;endpoint address="net.tcp://Address" binding="netTcpBinding" bindingConfiguration="Config" contract="Namespace.Contract" name="name"&gt; &lt;identity&gt; &lt;servicePrincipalName value="Host" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;/client&gt; &lt;bindings&gt; &lt;netTcpBinding&gt; &lt;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"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="None"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/netTcpBinding&gt; &lt;/bindings&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </code></pre> <p>I get the exception "An existing connection was forcibly closed by the remote host" every time the code reaches client.Open(). What really bothers is that when I try it from another computer, there's no exception. And on top of that, the config file used to have Transport security which was changed to None, and the computer where it works still has the old config file with</p> <pre><code>&lt;security mode="Transport"&gt; &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /&gt; &lt;message clientCredentialType="Windows" /&gt; &lt;/security&gt; </code></pre> <p>whereas on the first machine and the server it's</p> <pre><code>&lt;security mode="None"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;/security&gt; </code></pre> <p>What can cause this? I've read numerous other questions here regarding this exception, but none seemed to resemble my issue.</p> <p><strong>SOLVED! I have set the security options in the wrong place.</strong> The service was self hosted with ServiceHost, and the Security property wasn't set, so it defaulted to something else than None.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload