Mono WCF NetTcp service takes only one client at a time

Posted by vene on Stack Overflow See other posts from Stack Overflow or by vene
Published on 2010-05-31T14:54:00Z Indexed on 2010/06/02 1:43 UTC
Read the original article Hit count: 279

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about mono