5
votes

(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.

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?

1
Typically, after hours of troubleshooting i found the problem minutes after submitted this. I copied the WcfTestClient configuration over mine to find it. I have added <security mode="None"/> to both my service and client. But for some reason the client end point won't work like this. By changing it to <security mode="Transport"> <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> <message clientCredentialType="Windows" /> </security> The problem is now fixed. My service still has security mode none. Why?WebDude
Do you see the service listening on that port? in netstatrerun
This was only running internally. I made several successful calls to that port. netstat showed my service listening on that port. As per Aliostad's suggestion i have now changed my port to the 4000 rangeWebDude

1 Answers

8
votes

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.