Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65471

WCF 4 and NetTcpBinding

I am testing out the no configuration features of WCF 4.

I have built a simple service and deployed it to IIS. The service is deployed as a svc file

The client config is empty:

<configuration>
    <system.serviceModel>
        <bindings />
        <client />
    </system.serviceModel>
</configuration>

The config on the web server is:

<system.web>
   <compilation debug="true" targetFramework="4.0" />  
</system.web>   
<system.serviceModel>
   <behaviors>
      <serviceBehaviors>
         <behavior>
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
         </behavior>
      </serviceBehaviors>
   </behaviors>
   <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer>
   <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

This code works fine:

BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress("http://localhost/Service1.svc");
ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
IService1 wcfClient1 = myChannelFactory.CreateChannel();
int z = wcfClient1.Multiply(composite);

This code does not:

NetTcpBinding myBinding = new NetTcpBinding();
EndpointAddress myEndpoint = new EndpointAddress("net.tcp://localhost:808/Service1.svc");
ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
IService1 wcfClient1 = myChannelFactory.CreateChannel();
int z = wcfClient1.Multiply(composite);

The error that I get is:

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

The net.tcp binding is set on the default web site.

I have a feeling that there is something simple that I am missing. Anyone have any ideas?

Upvotes: 1

Views: 4317

Answers (2)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65471

Found the problem. Although net.tcp looked like it was installed for the Default web site it needed to be activated using this command:

 appcmd.exe set app "Default Web Site/" /enabledProtocols:http,net.tcp

Upvotes: 4

ChaosPandion
ChaosPandion

Reputation: 78302

I get the feeling that your Net.Tcp Port Sharing Service is not enabled.

Upvotes: 6

Related Questions