Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF client works only with local host
    text
    copied!<p>I have a wcf service hosted in a console process. Service endpoints creation is done through code, in the program.cs file using net tcp binding.</p> <p>Client side creation of channel is done through code. </p> <p>This setup works fine in local host. But if I host the service in other machine and if I try to connect to service from some other machine (client IP address is updated) then I get the below error.</p> <p><strong>System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://10.10.1.1:8232/Service/. The connection attempt lasted for a time span of 00:00:00. TCP error code 10061: No connection could be made because the target machine actively refused it 10.10.1.1:8232. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.10.1.1:8232</strong></p> <p><strong>Note:</strong> Other scenario => Service and client are running in same machine.</p> <p>In the service host to add the service endpoint URL address was given as 127.0.0.1.</p> <p>With this in the client side, if I specify the IP address of the same machine it could not able to connect to the service.</p> <p>But if I specify <strong>localhost</strong> instead of 127.0.0.1 in service endpoint configuration, I am able to connect successfully to the service.</p> <p>I'm not sure why it doesn't work with 127.0.0.1, but works with local host in same machine. Is this expected?</p> <p>Even after the local host change i could not able to connect to the service present in other machine.</p> <p>Any suggestions are welcome.</p> <p>The ports are not blocked by firewall. </p> <p>** Server side configuration through code **, </p> <pre><code>var tcpBinding = new NetTcpBinding(SecurityMode.None) { MaxBufferPoolSize = int.MaxValue, MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue, ReaderQuotas = { MaxArrayLength = int.MaxValue, MaxNameTableCharCount = int.MaxValue, MaxStringContentLength = int.MaxValue, MaxDepth = int.MaxValue, MaxBytesPerRead = int.MaxValue }, ReceiveTimeout = TimeSpan.MaxValue }; </code></pre> <p>var host = new ServiceHost(typeof(Service));</p> <pre><code> host.AddServiceEndpoint(typeof(IService), tcpBinding, "net.tcp://localhost:8232/Service/"); host.Open(); Console.ReadLine(); host.Close(); ` </code></pre> <p>** Clinet side configuration ** </p> <pre><code> string endPointAdress = "net.tcp://10.10.1.1:8232/Service"; </code></pre> <p>var ServiceProxy = ChannelFactory.CreateChannel( tcpBinding, new EndpointAddress(endPointAdress));</p> <p>*/ tcp binding is same for both client and service.</p> <p>Can this problem happen due to data contracts? But if it is it should not work for local host as well. Please correct, if my understanding is wrong.</p> <h1>Solution</h1> <p>Changing the server configuration from </p> <p>** net.tcp://127.0.0.1:8232/Service/ ** to ** net.tcp://localhost:8232/Service/ ** seems to fix the problem. And the mentioned solution may be helpful to some one. May be some one can help why is this? Thanks all.</p>
 

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