WCF net.tcp - connection rejected by the target machine

I have a problem with Windows 8 x 64, as well as with Windows 7 x 64. I have a simple WCF service that uses net.tcp binding.

I wrote several articles to write this simple service, including the following on MSDN: Hosting and Using WCF Services

My service and configuration files are exactly the same as indicated in the previous article.

After installing this WCF service using InstallUtil.exe as a service window, I see that the service is installing correctly and it works without errors. I tried adding traces to the OnStart and OnStop methods of the Windows service and did not find anything wrong. As soon as I try to reference this endpoint from another solution, I will get the following error.

Failed to connect to net.tcp: // localhost: 8523 / Inbound. The communication attempt lasted for 00: 00: 00.9531494. TCP error code 10061: The connection could not be completed because the target machine actively refused it 127.0.0.1:8523.

I tried most of the messages related to this problem via the Internet, and I also tried to open firewalls, disable antivirus software, try different ports, explicitly create incoming and outgoing rules for these ports in the firewall, etc. I can’t access this Windows service that hosts my net.tcp based WCF service. TCP port sharing services and TCP list adapter services are enabled, and I also enabled the unnecessary Windows features needed to run these TCP services.

, , - , , Visual Studio Wcf Service Host (WcfSvcHost), , . , .

Windows, , , . , ServiceHost . , . , , . , Visual Studio , , .

: WcfSvceHost ? , . , , .

- Windows ServiceHost ? - ? . .

.

<system.serviceModel>
<bindings />
<client />
<services>
  <service name="MyWcfServiceLibrary.WCFService">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="" name="TCPEndPoint" contract="MyWcfServiceLibrary.IWCFService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" name="mexEndPoint" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://127.0.0.1:8523/MyWCFService" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>        
    <behavior name="">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>
+4
1

. ? TCP- . Microsoft " ​​ WCF, ".

Net.TCP MMC

  • "" , services.msc, "" "services.msc" "".
  • "" Net.Tcp "" .
  • , "" "" " " "", "".
  • , "". "".
  • , "" MMC.

NetTcpBinding .

<system.serviceModel>
  <bindings>
    <netTcpBinding name="portSharingBinding" 
                   portSharingEnabled="true" />
  </bindings>
  <services>
    <service name="MyService">
        <endpoint address="net.tcp://localhost/MyService"
                  binding="netTcpBinding"
                  contract="IMyService"
                  bindingConfiguration="portSharingBinding" />
    </service>
  </services>
</system.serviceModel>

, , 8523. Netstat -a TCPView . TCPView

+1

Source: https://habr.com/ru/post/1621976/


All Articles