views:

9258

answers:

3

I have developed a WCF service that uses the net.tcp adapter and listens to a specific port. I want to connect to that service using a normal .net client that uses sockets to send data to the port and listens to responses.
When I try to send data to this service, I get the error: "The existing connection was forcibly closed by remote host".
However, i am able to connect with the service by another client which uses the Address/Binding/Contracts of the WCF service.
Is there a way that enables me to communicate with a WCF service by using an ordinary socket based client?

A: 

Hy,

did you enable the WCF Tracing? Because if you do and you get the following message: "The service does not allow you to log on anonymously." then it is (usually) a security setting problem.

In this case disable the security mode for your binding:

<netTcpBinding>
   <binding name="MyCustomBinding"> 
      <security mode="None" /> 
   </binding> 
</netTcpBinding>

But better would be to work with certificates.

TomTom
+11  A: 
EnocNRoll
My answer definitely does not deserve to be downvoted.
EnocNRoll
but you criticised the wonderful WCF, so therefore you need to be taken outside and shot :) - have +1 from me though.
gbjbaanb
Thanks, I try to make my answer useful and I always update them if they are incorrect in any way. I view them as references for my personal knowledge also, not simply for points on StackOverflow.
EnocNRoll
Great answer EnocNRoll. Very impressive. A definite +1 ;)
Burhan
I upvoted the question so now you have enough reputation to upvote. You had only 11, but 15 are needed. Now you have 21. Welcome to StackOverflow.
EnocNRoll
So go ahead and try out your new power by reattempting to upvote my answer. Thanks.
EnocNRoll
+4  A: 

The Net.TCP binding uses a custom wire-level framing format that is not really documented, though Nicholas Allen started a series of blog posts on the topic recently. The series start here: http://blogs.msdn.com/drnick/archive/2009/01/19/message-framing-part-1.aspx

To be honest, Net.TCP is really, currently, more useful for WCF to WCF communication. if you want to interop with a custom TCP format that you need to handle, you're much better off either using raw sockets or creating your own custom WCF transport channel (which might not be trivial, btw)

tomasr