Mono WCF client cannot talk with .NET WCF server when transport security is enabled

This is how I start the 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 is 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 the client and the server using the Mono 2.10 runtime, everything works. But when the 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 confirmed that with binding.Security.Mode = SecurityMode.None everything works fine. Is there any chance that I can somehow get these two interaction modes to interact with properly working security?

+4
source share
1 answer

Unfortunately, NetTcpBinding support NetTcpBinding very limited in Mono and does not support any security.

If you look only at the source of NetTcpBinding.cs , it might seem like this, but if you look at the actual binding of the elements, you will see many methods that are not implemented.

I really ran into the same problem a couple of days ago when I was working on my new WCF configuration system, I wanted NetTcpBinding work with security, and when I investigated why it didn’t work, I realized that too much was not implemented, so probably It’s a more difficult task to make it work.

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

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

+5
source

All Articles