Mono WCF NetTcp service takes only one client at a time
Asked Answered
T

2

6

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.

Taradiddle answered 31/5, 2010 at 14:54 Comment(3)
What does the service look like? How are you connecting? What I'm getting at is the Duplex aspect... I don't know how well (if at all) Duplex works in Mono. Did you try running the endpoint like this and just using a simple, simplex service?Portend
I eventually need to be using Duplex but this basic example that we reverted to is a simple simplex service. As far as I can tell it should work right, and it DOES work with BasicHttp. I'll update the question with the rest.Taradiddle
In case you missed it, it looks like this might be fixed now. See alexcepois bug report: bugzilla.novell.com/show_bug.cgi?id=610659Portend
P
3

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.

Portend answered 31/5, 2010 at 20:50 Comment(3)
Maybe in some older version of Mono it works, did anybody had any good experiences with such a scenario?Taradiddle
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.Portend
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.Taradiddle
W
1

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.

Widget answered 2/6, 2010 at 1:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.