While trying to create a WCF client-server application in Mono, we encountered some problems. Having reduced it to a simple example, we found that the service only accepts one customer at a time. If another client tries to connect, it freezes until the first one disconnects.
A simple change to BasicHttpBinding fixes it, but we need NetTcpBinding for duplex communication. Also, the problem does not occur if compiled in 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
Here's how the service opens in our base case:
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 as follows:
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, right?
The contract is simple:
[ServiceContract] public interface IHello { [OperationContract] string Greet (string name); }
The service implementation does not have ServiceModel tags or attributes.
I will update the necessary data.
mono wcf nettcpbinding
vene
source share