tags:

views:

493

answers:

1

I've written and rolled out to a customer an app that uses NetTcpBinding for communicaions.

I've got a server app which accepts subscription requests from clients, then pushes data to the clients.

The client is seeing an issue on site where the once the server has 5 clients connected to it it refuses any more.

Has anyone seen this kind of behaviour before? Does anyone know what might be causing this? It works perfectly for less users.

I'm attempting to diagnose this myself at the moment but I'm new to WCF so I was wondering if there was some common solution to this kind of problem?

I get the following stack trace (Sanitzes to remove client name and product name):

2009-09-30 13:03:16,308 [1] ERROR [(null)] - Failed to subscribe to the VDN server, there was no server listening for connections at the configured URI
System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://server:4000/VDNService. The connection attempt lasted for a time span of 00:00:01.0312236. TCP error code 10061: No connection could be made because the target machine actively refused it 10.65.1.42:4000.  ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.65.1.42:4000
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ClientLib.IServer.Subscribe(List`1 groups)
   at ClientLib.Client.Subscribe(List`1 groupNames)
+2  A: 

A few questions up front:

  • On your server side, what does you config look like?
  • What OS is the server running under? (some OS versions/editions have limitations)
  • How are you hosting your WCF service on that server? (IIS vs. self-hosting)

You can basically tweak the number of concurrent connections using the ServiceThrottling behavior, and you can define

  • maximum number of concurrent calls
  • maximum number of concurrent sessions (including TCP/IP transport sessions)
  • maximum number of service class instances

To configure, try this:

<serviceBehaviors>
    <behavior name="throttledService">
      <serviceThrottling 
          maxConcurrentCalls="10"
          maxConcurrentInstances="10"
          maxConcurrentSessions="10"/>
    </behavior>

and of course, your service configuration will then have to reference that behavior configuration.

None of those default to 5, though :-( But in your case, I'd try to crank up all the settings to 25 or something and just see if that makes any difference, and then tweak to your needs (and monitor the server's CPU and memory load!).

Marc

UPDATE:
You can definitely also do this in code - something like this (on the server side, where you instantiate your ServiceHost class, if you self-host):

using (ServiceHost host = new ServiceHost(typeof(MyWCFService)))
{
    ServiceThrottlingBehavior stb = new ServiceThrottlingBehavior();
    stb.MaxConcurrentCalls = 25;
    stb.MaxConcurrentInstances = 25;
    stb.MaxConcurrentSessions = 25;

    host.Description.Behaviors.Add(stb);

    host.Open();

    ...
}
marc_s
There is no WCF config file for this application as I hand coded the WCF component based on a tutorial.I'll have a look to see if there might be a way to change these variables in code.
Omar Kooheji
The binding has a MaxConnections property which I'm goping to try. Thanks for your help.
Omar Kooheji
OK but are you self-hosting (console app, NT Service) or hosting in IIS?
marc_s
It's in a self hosted NT service running on windows Server 2003 R2 SP2 Standard edition.
Omar Kooheji