views:

300

answers:

2

While trying to build a client-server WCF application in Mono we ran into some issues. Reducing it to just a bare example we found that the service only accepts one client at a time. If another client attempts to connect, it hangs until the first one disconnects.

Simply changing to BasicHttpBinding fixes it but we need NetTcpBinding for duplex communication. Also the problem does not appear if compiled under MS .NET.

EDIT: I doubt (and hope not) that Mono doesn't support what I'm trying to do. Mono code usually throws NotImplementedExceptions in such cases as far as I noticed. I am using Mono v2.6.4

This is how the service is opened in our basic scenario:

public static void Main (string[] args)
{
    var binding = new NetTcpBinding ();
    binding.Security.Mode = SecurityMode.None;
    var address = new Uri ("net.tcp://localhost:8080");
    var host = new ServiceHost (typeof(Hello));
    host.AddServiceEndpoint (typeof(IHello), binding, address);

    ServiceThrottlingBehavior behavior = new ServiceThrottlingBehavior ()
    {
        MaxConcurrentCalls = 100,
        MaxConcurrentSessions = 100,
        MaxConcurrentInstances = 100            
    };
    host.Description.Behaviors.Add (behavior);

    host.Open ();
    Console.ReadLine ();
    host.Close ();

}

The client channel is obtained like this:

var binding = new NetTcpBinding ();
binding.Security.Mode = SecurityMode.None;
var address = new EndpointAddress ("net.tcp://localhost:8080/");
var client = new ChannelFactory<IHello> (binding, address).CreateChannel ();

As far as I know this is a Simplex connection, isn't it?

The contract is simply:

[ServiceContract]
public interface IHello
{

    [OperationContract]
    string Greet (string name);
}

Service implementation has no ServiceModel tags or attributes.

I'll update with details as required.

+2  A: 

I've played around with this a bit, and it definitely looks like a Mono bug.

I'm porting a WCF application to run in Mono at the moment. I had played with some NetTcpBinding stuff, but I hadn't tried this scenario (multiple connections to a Mono-hosted service host). However now I try it out, I'm able to reproduce - both in 2.6 and the latest daily package.

It does work in .NET, however. Any difference in behavior between Mono and .NET is classed as a bug. You should log it on Bugzilla with a test case, I would also post in the Mono newslist.

Good luck.

TheNextman
Maybe in some older version of Mono it works, did anybody had any good experiences with such a scenario?
vene
WCF really wasn't worth bothering with in 2.4, it was more of a preview than anything else. A lot of scenarios work in 2.6, but lots is not implemented and lots is broken. They have fixed a lot of the broken stuff in 2.8, which was why I was quite hopeful when I tested against the latest daily; but no dice. I'm interested in following any progression you make with this as I would like to use NetTcpBinding (without duplex, though) in a project I'm working on.
TheNextman
Indeed it seems the Mono NetTcpBinding is broken at the moment. I even tried writing a headless server running under Windows with .NET, in order to only use the client-side of the duplex binding under Mono. That didn't work either.
vene
+1  A: 

Definately a bug. I'm wondering if there was a version it was working correctly...

I've posted it at Novell Bugzilla, if you are interested in its progress.

alexcepoi