locked
No more than 10 connections problem RRS feed

  • Question

  • Hello,

    I have a WCF service (wsHttpBinding) which is an event propogation server of some sort.

    There is a function Subscribe(address) and when service recieves that call from client it caches that client in its invocation list (address is a callback destination of that client). Then when time comes and server needs to propogate some message to all subscribers, I iterate through that list and call clients. Client, consequently have little servers setup on their end so that server can communicate to them.

    Here is how I broadcast messages back to clients.

    for(int i = 0; i < currentConnections.Length; i++)
    {

    using (CallbackContractClient client = new CallbackContractClient("CallbackClient", currentConnectionsIdea))
    {

    try
    {

    if(!client.Endpoint.Address.Uri.OriginalString.Equals(currentMessage.Initiator))
    {

    client.DoSomething(currentMessage.Message);//Here is some message
    ServerOperationPerformed(
    string.Format("Client [{0}] notified of message [{1}]", client.Endpoint.Address.Uri.OriginalString,currentMessage.Message));

    }

    }
    catch
    {

    ServerOperationPerformed(

    string.Format("Failed to notify client [{0}] of message [{1}]", client.Endpoint.Address.Uri.OriginalString, currentMessage.Message));

    try{client.Close();}catch{}//How do I dispose connection?

    }

    }

    }

    Now if I initiate more than 10 clients and then drop (shutdown process or close call back server) them, 11th client will hang on Subscribe call. Server will never receive that Subscribe call and client will block waiting for response (and will error out on timeout).

    It appears that when server calls back clients and those clients error out (either server is down on client side or some communication problem) channel still lives for some reason and there seems to be a limit of 10 concurrent channels that are not reused by other (new) clients...

    Am I doing something wrong?

    Ideally, I want my event propogation server live and accept new clients regardless of any other clients it has in its invocation list. If some clients bomb out, new clients should not be affected.

    Help is very much appreciated.

    Wednesday, March 21, 2007 8:34 PM

Answers

  • Finally!

    The problem was that when I propogated messages back to clients, if cal had failed, I had to do

    client.Abort()

    otherwise, it had kept a channel open for some reason, even though client end was down...

    Rodion

    Friday, March 23, 2007 5:50 PM

All replies

  • Are you hosting on XP?

    XP has a built-in limit of 10, you would need an actual server with the appropriate CAL (client access licences).

    If your not using XP, then look into at the maxConnections of the binding configuration and this section for the behavior of the service:

    <serviceThrottling maxConcurrentCalls="64"
       
    maxConcurrentSessions="64"
       
    maxConcurrentInstances="250" />
    <
    serviceCredentials>

    I suspect you are using XP and/or the maxConnections is at its default of 10.

    Trevor

    *NOTE: I am no WCF expert and my advice may be faulty, but I like to try and help

    Wednesday, March 21, 2007 9:21 PM
  • Thank you Trevor,

    I am using win2003 server (I knew that problem about XP), so I can have more concurrent connections. The problem is that it doesn't allow no more than 10 NON CONCURRENT connection. That's what throws me off... after 10 clients have connected and then dropped I can no longer connect...

    I tend to think that, since I'm caching connection back to clients on the server, they are not properly disposed when client dies.

    Help is very much appreciated...

    Rodion

    Thursday, March 22, 2007 12:13 PM
  • Does your binding specify the throttling? You didn't answer.

    I forget what the default is, but it is low.

    Trevor

    Thursday, March 22, 2007 6:15 PM
  • Yes I tried,

    the result was that instead of 10 connections it allowed me to make 64 (paralel or sequential, didn't matter) connection. When I tried to initiate 65th connection, it hang...

    Rodion

    Friday, March 23, 2007 3:46 PM
  • Finally!

    The problem was that when I propogated messages back to clients, if cal had failed, I had to do

    client.Abort()

    otherwise, it had kept a channel open for some reason, even though client end was down...

    Rodion

    Friday, March 23, 2007 5:50 PM