none
TCP error code 10061: No connection could be made because the target machine actively refused it

    Question

  • I have a wcf service which hosted in a windows service.  Additionally, I have a wpf app that connects to the wcf service.  I have been unable to open the wpf program.  This is the error I get when I attempt to open the wpf app ( this from the trace file ) :

    TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000.

    I have firewall switched off.  I do have both Http and Non-http activation options on under the wcf activation node of selected features.  all 3 services to do with net.tcp are running  : net.pipe and the 2 other net.tcp services.  app.config file of the windows service has the following setup :

    system.serviceModel>
        <services>
          <service name="WcfServiceLibrary2.Service1">
            <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="WcfServiceLibrary2.IService1">
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:8000/Service1"/>
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="false"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

    and the app.config file of the wpf file has the following :

    <client>
                <endpoint address="net.tcp://localhost:8000/Service1" binding="netTcpBinding"
                    bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
                    name="NetTcpBinding_IService1">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
            </client>

    is there anything else I should do ?

    regards

    Thursday, January 23, 2014 3:41 PM

Answers

  • Hi,

    >>TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000.

    When occur the above error, either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different port.

    Once you start the process hosting your service try netstat -a (requires admin privileges) to verify that it is running and listening on the expected port.
    Also ensure the appropriate Windows Services are running, e.g. Net.Tcp listener

    Then please try to set the includeExceptionDetailInFaults to true to get more information about exception:

    <serviceDebug includeExceptionDetailInFaults="true"/>
    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 24, 2014 7:10 AM
    Moderator
  • I was able to resolve this issue.  I had added the following bit of code in the windows service onstart method

      myServiceHost = new ServiceHost(typeof(Service1));
                myServiceHost.Open();

    Service1 is the name of the windows class service.  It should have been 

      myServiceHost = new ServiceHost(typeof(WCFService));
                myServiceHost.Open();
    Apologies for wasting anybodys time in sorting this out.

    Wednesday, January 29, 2014 10:46 AM

All replies

  • Hi,

    >>TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000.

    When occur the above error, either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different port.

    Once you start the process hosting your service try netstat -a (requires admin privileges) to verify that it is running and listening on the expected port.
    Also ensure the appropriate Windows Services are running, e.g. Net.Tcp listener

    Then please try to set the includeExceptionDetailInFaults to true to get more information about exception:

    <serviceDebug includeExceptionDetailInFaults="true"/>
    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 24, 2014 7:10 AM
    Moderator
  • Hi Amy

    thanks for you reply.  as said in my initial details, the firewall is switched off.  I have done a netstat -a and found that port 8000 is not on the list.

    How do I set up my windows hosted wcf service so that port 8000 is listening ?


    Friday, January 24, 2014 10:07 AM
  • Not heard from anybody as yet.... Is there anybody that can help with this issue ?  Just that Im totally stuck..
    Monday, January 27, 2014 4:22 PM
  • I was able to resolve this issue.  I had added the following bit of code in the windows service onstart method

      myServiceHost = new ServiceHost(typeof(Service1));
                myServiceHost.Open();

    Service1 is the name of the windows class service.  It should have been 

      myServiceHost = new ServiceHost(typeof(WCFService));
                myServiceHost.Open();
    Apologies for wasting anybodys time in sorting this out.

    Wednesday, January 29, 2014 10:46 AM
  • Thanks pbmorpeth, would never have spotted that, I guess that's what happens if you use too many templates, think the template would be better written as :-

    myServiceHost = new ServiceHost(typeof(WcfServiceLibrary1.Service1));

    myServiceHost.Open();

    to avoid the scope clash with the Service1 from the Windows Service host.

    You saved me a good few hours,

    cheers

    Monday, June 9, 2014 5:04 PM