Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service call working with basicHttpBinding but fails with netTcpBinding

(Please read comment as i have a fix)
Hi,

I have created a WCF Service that i am hosting in IIS 7.5 on Windows 7 using .net 4.0
The service is hosted both on http and net.tcp.

  • net.tcp://localhost:42/Service/MyService.svc
  • http://localhost:43/Service/MyService.svc

I have tested my service using the WcfTestClient and it seems to work correctly through both basicHttp and netTcp.

However, when i try consume this service through my ASP.NET Website, i receive an error when trying to go through nettcp

My client end point looks as follows

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="Generic_HttpBinding" sendTimeout="00:01:00" receiveTimeout="00:01:00" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000">
      <security mode="None"/>
      <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000"/>
    </binding>
  </basicHttpBinding>
  <netTcpBinding>
    <binding name="Generic_Binding" sendTimeout="00:01:00" receiveTimeout="00:01:00" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000">
      <security mode="None"/>
      <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000"/>
    </binding>
  </netTcpBinding>
</bindings>
<client>
  <endpoint name="EndPointHttp" address="http://localhost:43/Service/MyService.svc" binding="basicHttpBinding" bindingConfiguration="Generic_HttpBinding" contract="NameSpace.Services.Contracts.IService"></endpoint>
  <endpoint name="EndPoint" address="net.tcp://localhost:42/Service/MyService.svc" binding="netTcpBinding" bindingConfiguration="Generic_Binding" contract="NameSpace.Services.Contracts.IService"></endpoint>
</client>

Now i call the service in the exact same way just swapping my end point name

var factory = new ChannelFactory<IService>(SuppliedEndpointName);
factory.Open();
var proxy = factory.CreateChannel();
var result = proxy.SomeServiceMethod();

If i pass this method the basicHttpBinding it works perfectly.
The second i swap to nettcp, i receive this error immediately:

Exception: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'.

Inner Exception: An existing connection was forcibly closed by the remote host

Error Code: 10054

Please can anyone help me, it driving me crazy.
I have definately installed the WCF HTTP Activation and NON HTTP Activation features.
I have setup my binding to be both HTTP and net.tcp on differen't ports.
I have set my enabled protocols to http,net.tcp in IIS.
I have disabled my firewall. I have run aspnet_regiis -i for .net 4.0

HELP!


I finally found that changing my security mode to transport fixes the problem.
However my service has it security mode set to none.
So why does my client only works with security mode transport on?

like image 799
WebDude Avatar asked Apr 14 '11 21:04

WebDude


1 Answers

netTcpBinding by default transport security with both signing and encryption. Try removing the security element (<security mode="None"/>).


Also

Ports under 8000 (and definitely under 1024) are normally not safe to be used for services. Try using safe ports.

like image 198
Aliostad Avatar answered Nov 06 '22 02:11

Aliostad