2
votes

I am trying to host a WCF Service with Net TCP bindings in IIS 7 / Win 7. The service is hosted and i can add a reference to it in my client application.

Here is the service configuration file:

  <configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.0" />

    </system.web>
    <system.serviceModel>
      <bindings>
        <netTcpBinding>
          <binding name="InsecureTcp" portSharingEnabled ="true">
            <security mode="None">
              <transport clientCredentialType="None" protectionLevel="None" />
            </security>
          </binding>
        </netTcpBinding>
      </bindings>
      <services>
        <service name="ApplicationProcessService">
          <endpoint address="" binding="netTcpBinding" bindingConfiguration="InsecureTcp"
            name="NetTCP_Port10000" contract="IApplicationProcess" />
          <endpoint address="mex" binding="mexHttpBinding" name="mexNetTCP_Port10000"
            contract="IMetadataExchange" />
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
      <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
        <baseAddressPrefixFilters>
        </baseAddressPrefixFilters>
      </serviceHostingEnvironment>

    </system.serviceModel>
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>

  </configuration>

And here is the configuration generated at client when I add the reference:

<configuration>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTCP_Port10000" 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">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:10000/ApplicationProcess.svc"
          binding="netTcpBinding" bindingConfiguration="NetTCP_Port10000"
          contract="ApplicationProcessService.IApplicationProcess" name="NetTCP_Port10000" />
    </client>
  </system.serviceModel>
</configuration>

The problem is at run time, i get the following error:-

Could not connect to net.tcp://localhost:10000/AppServer.ApplicationProcess.svc. The connection attempt lasted for a time span of 00:00:02.0582058. TCP error code 10061: No connection could be made because the target machine actively refused it.

I have followed the steps described in http://www.singingeels.com/Articles/Duplex_WCF_Services_Hosted_in_IIS_Using_NetTcp.aspx

and created an inbound rule in my firewall allowing TCP communication on port 10000. I am not sure what am i missing. Any thoughts?

3
found similar question, but i am not making that mistake. [stackoverflow.com/questions/4820172/how-to-setup-wcf-net-tcp]Apurv
Did you ever figure this out? stackoverflow.com/questions/16628382/…Niels Brinch

3 Answers

2
votes

The key here is is that you have enabled port sharing (PortSharingEnabled in your bindings) which requires that you run the TCP Port sharing service, which is not running by default in Windows. See this link: NetTcpBinding.PortSharingEnabled

2
votes

In addition to the Net.Tcp Port Sharing Service that was mentioned previously, you'll also need to enable and start Net.Tcp Listener Adapter service.

0
votes

In addition to the services that needed to be enabled I also had to enable IIS to recognize net.tcp. Right-click your website > Manage Application > Advanced Settings. The value for Enabled Protocols should be: http,net.tcp