none
WCF Service cross machine refuses connection tcp error 10061

    Question

  • I have a Test WCF Service to communicate between a surface tablet an my pc.

    The target computer is visible in the Network. The target computer refuses the connection (tcp error 10061). I developed WCF Services to communicate with web servers and Windows Phone communicating with PC: No problems; what is wrong here:

    ServerApp:

    App.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
        </startup>
    
      <system.serviceModel>
        <services>
          <service name="MyTcpService.Service1" behaviorConfiguration ="netTcpServiceBehavior">
            <endpoint address ="" binding="netTcpBinding" contract ="MyTcpService.IService1" />
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
            <host>
              <baseAddresses >
                <add baseAddress ="net.tcp://Atman/SampleNetTCPService"/>
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="netTcpServiceBehavior">
              <serviceMetadata httpGetEnabled="false" httpGetUrl=""/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors >
        </behaviors >
    
      </system.serviceModel>
      
      
    </configuration>

    Host the WCF Service:

    _host = new ServiceHost(typeof(MyTcpService.Service1));
                _host.Open();

    Client: App.Config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
        </startup>
        <system.serviceModel>
          <bindings>
            <netTcpBinding>
              <binding name="NetTcpBinding_IService1"
                       closeTimeout="00:10:00"
         openTimeout="00:10:00"
         receiveTimeout="00:10:00"
         sendTimeout="00:10:00"  />
            </netTcpBinding>
          </bindings>
            <client>
                <endpoint address="net.tcp://Atman/SampleNetTCPService.svc" binding="netTcpBinding"
                    bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
                    name="NetTcpBinding_IService1">
                </endpoint>
            </client>
        </system.serviceModel>
    </configuration>

    Client calls TestMethod:

    try
                {
                    ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
    
                    string result = client.GetData(16);
    
                    MessageBox.Show(result);
    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
    Using the code on same machine everything works fine. I copy the client app to a different machine an got the tcp error 10061, refusing the connection.

    Why the service is blocked or the connection is refused?

    I tried it with firewall full open.

    Any help?

     

    Thanks!

    Friday, August 16, 2013 5:39 PM

Answers

  • Hello to all

    I've got now the solution or better what the problem was:

    My client computer had the same name as the server computer! Both were "Atman". So the WCF Service on the client looked for a WCF Service on "Atman" which was the client computer but there's no such service...

    Sorry for using your time.

    And thank you all.

    Stefan

    Monday, August 19, 2013 1:25 PM

All replies

  • This still looks like a firewall issue to me. Just another question - your client config has this endpoint address (net.tcp://Atman/SampleNetTCPService.svc) but your service is hosted at net.tcp://Atman/SampleNetTCPService. Can you try to fix this and see by chance? 
    Saturday, August 17, 2013 7:35 PM
  • I turned the firewall off and it did not work. I changed the endpoint adress to *.svc because of trying. Yes right I will change it back.

    Firewall: I think that if the connection is refused, its not a problem that the WCF Service is not found. I turned the firewall off. So why the WCF Service is refused. I could not find a good sample for cross machine WCF Service (including Firewall Problem, ...).

    Thank you for your answer.

    Sunday, August 18, 2013 7:07 AM
  • Hi,

    The most common problem is that the Windows Service Net.Tcp Listener Adapter is not running on the hosting machine. Then the services are not hosted well.

    Also please check your IIS Web Application to ensure Enabled Protocols includes net.tcp.

    Here are some similar threads, please try to refer to:
    http://social.msdn.microsoft.com/Forums/en-US/aa8fc571-53e0-4345-9ca5-7822dcf64ee0/wcf-service-cant-be-connected-tcp-error-10061 .

    http://social.msdn.microsoft.com/Forums/en-US/23875a64-e264-457a-b6ed-58cc41399965/tcp-error-code-10061-no-connection-could-be-made-because-the-target-machine-actively-refused-it .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 19, 2013 2:06 AM
    Moderator

  • Hi tegralFramework.Net,

    From the configuration you provided, I found that you haven't explicitly specify security mode for your WCF service (server-side). Then the default is using windows authentication at transport layer. And when you move your WCF service to be called from remote client machines, if the client machine's execution account cannot be recognized at  the server machine, error will occur. So you can do a quick test to turn off security for testeing to see if that can eliminat the error. e.g.

    <netTcpBinding>
              <binding name="tcpbinding1" >
        <security mode="None">
      </security>
     </binding>
                       
    </netTcpBinding>

     

    #Bindings and Security
    http://msdn.microsoft.com/en-us/library/ms731172.aspx

    #<security> of <netTcpBinding>
    http://msdn.microsoft.com/en-us/library/ms731316.aspx


    In addition, here are some online threads talking about similar errors and some troublehsooting suggestions:

    http://social.msdn.microsoft.com/Forums/en-US/40ffc101-25b8-4a9c-bc99-9bde77fe095c/nettcp-binding-connection-actively-refused-intermittent

    http://stackoverflow.com/questions/1247172/connection-refused-nettcp-wcf-service-from-work-client-connecting-over-vpn


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 19, 2013 3:47 AM
    Moderator
  • Hi Amy

    The Listeners you mentioned are all running.

    Is it possible that this is a network problem? Is my networ not properly installed?

    Best regards.

    Stefan

    Monday, August 19, 2013 12:53 PM
  • Hello Steven

    I developed a new WCF Test Service and included the security mode = None. The server refuses the connection.

    How can I get more Information?

    One of your links included:

    proxy.ClientCredentials.Windows.ClientCredential.UserName = "clientaccount";
    proxy
    .ClientCredentials.Windows.ClientCredential.Password = "S3cr3t1337Pwd";

    Are these credentials needed? Which UserName and Password should I take. These from the server?

    Thank yoo

    Stefan

    Monday, August 19, 2013 12:56 PM
  • Hello to all

    I've got now the solution or better what the problem was:

    My client computer had the same name as the server computer! Both were "Atman". So the WCF Service on the client looked for a WCF Service on "Atman" which was the client computer but there's no such service...

    Sorry for using your time.

    And thank you all.

    Stefan

    Monday, August 19, 2013 1:25 PM
  • Thanks for your reply  Stefan!

    Glad that you've figured out the issue.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, August 20, 2013 9:12 AM
    Moderator