77vetter
77vetter

Reputation: 193

WCF NetTcp Configuration Issue

We are having problems getting netTcp configured for our WCF WebService which is hosted locally in IIS. This is on a Windows 7 and IIS 7 with DotNet 4.0 (VS2012), Firewall is disabled.

We have done the following steps to configure netTcp:

  1. In IIS, set Site Bindings for net.tcp 808:* for Default Web Site
  2. In IIS for our web service the Enabled Protocols are "http,net.tcp" (no spaces)
  3. Verified Net.Tcp Listener Adapter and Net.Tcp Port Sharing Services are running (recycled them as well)

Now when we run netstat -ona we do not see any listing for 127.0.0.1:808 - should we???

Here is my Web.config:

<system.web>
<customErrors mode="Off"></customErrors>
<compilation debug="true" targetFramework="4.0"></compilation>
    <identity impersonate="false" />
</system.web> 
<system.serviceModel>
<diagnostics>
  <messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false"
    logMessagesAtTransportLevel="false" />
</diagnostics>
<bindings>
  <netTcpBinding>
    <binding name="XxxxxxxCommonServiceBinding"  />
  </netTcpBinding>
</bindings>
<services>
  <service behaviorConfiguration="XxxxxxxCommonService_Behavior" name="CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService">
    <endpoint address="net.tcp://localhost:808/CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService/XxxxxxxCommonService.svc" binding="netTcpBinding"
              bindingConfiguration="XxxxxxxCommonServiceBinding" name="XxxxxxxCommonNetTcpBinding"
              contract="CS.ServiceContracts.Xxxxxxx.Common.IXxxxxxxCommonService" />
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />      
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="XxxxxxxCommonService_Behavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false">      
 </serviceHostingEnvironment>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

And here is the App.config:

<system.serviceModel>
<client>
  <endpoint name="CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService"
            address="net.tcp://localhost/CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService/XxxxxxxCommonService.svc"
            binding="netTcpBinding"
            bindingConfiguration="XxxxxxxCommonNetTcpBinding"
            contract="CS.ServiceContracts.Xxxxxxx.Common.IXxxxxxxCommonService"/>
</client>    
</system.serviceModel>

Here is code in my client where I attempt to call the service:

var endPoint = new EndpointAddress(
            "net.tcp://127.0.0.1:809/CS.WebService.Xxxxxx.Common.XxxxxxCommonService/XxxxxxCommonService.svc");
var binding = new NetTcpBinding { TransferMode = TransferMode.Streamed, SendTimeout = TimeSpan.MaxValue };
var channel = new ChannelFactory<IXxxxxxCommonService>(binding, endPoint);
var proxy = channel.CreateChannel()
var request = new GetDataRequest();
var response = proxy.GetData(request);

It is at this point where we get the following error:

Could not connect to net.tcp://127.0.0.1:809/CS.WebService.Xxxxxx.Common.XxxxxxCommonService/XxxxxxCommonService.svc. 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 127.0.0.1:809.

If I change the port in the code and WebConfig to 808 we get the following error:

There was no endpoint listening at net.tcp://127.0.0.1/CS.WebService.Xxxxxx.Common.XxxxxxCommonService/XxxxxxCommonService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. (note, there was no inner exception)

So it seems to me that because netstat -ona does not show 127.0.0.1:808 that I dont have something configured properly. But again the Net.Tcp services are running and have been recycled and I believe IIS is setup correctly as well so not sure where to turn.

Upvotes: 2

Views: 2029

Answers (2)

77vetter
77vetter

Reputation: 193

Changed SessionMode.Allowed on both client and server and everything started working. I was also having memory issues on my pc so once I cleared out memory and got the sessionMode correct all is well. Turning tracing on is what pointed me in the right direction.

Upvotes: 1

YK1
YK1

Reputation: 7612

Go to Control Panel > Programs and Features > Turn Windows Features on or off. In the subsequent dialog, go to entry Microsoft .NET Framework 3.5.1 and enable Windows Communication Foundation Non-HTTP Activation. (Although it says 3.5.1 - which Win7 built in framework - it works for 4.0 as well).

You should see 0.0.0.0:808 in netstat output.

Upvotes: 1

Related Questions