Question

Here is how I run WCF host:

var baseAddress = new Uri("net.tcp://localhost:2222/blah");

var binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Transport;

var sh = new ServiceHost(typeof(MyServiceImpl), baseAddress);
sh.AddServiceEndpoint(typeof(IMyService), binding, baseAddress);
sh.Open();

Here's my client:

Uri uri = new Uri("net.tcp://localhost:2222/blah");
var address = new EndpointAddress(uri);
var binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Transport;
var client = new MyServiceClient(binding, address);
client.Open();

When I execute both client and server using Mono 2.10 runtime, all works. But when server is running on .NET 4.0, I get a System.IO.IOException: Read failure ---> System.Exception: An existing connection was forcibly closed by the remote host. I also verified that with binding.Security.Mode = SecurityMode.None all works fine. Is there a possibility that I could somehow make those two runtimes interoperate with properly working security?

Was it helpful?

Solution

Unfortunately, support for NetTcpBinding is very limited in Mono and it does not support any kind of security.

If you only look at the source of of NetTcpBinding.cs, it may appear that it does, but if you look at the actual binding elements, you'll see a lot of methods that are not implemented.

I actually ran into the same problem a couple of days ago while I was working on my new WCF configuration system, wanted to get NetTcpBinding working with security and when I investigated why it was not working, I realised that too much is not implemented, so it's probably a larger task to get it working.

Also note that by default, NetTcpBinding uses WindowsStreamSecurityBindingElement - unfortunately, I could not find any documentation on the underlying transport mechanism.

Use BasicHttpBinding or the new BasicHttpsBinding if you're using .NET 4.5 (it will also be available in MonoTouch shortly).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top