Search code examples
c#wcf

How to increase Max connections WCF NET TCP


I'm setting the WCF NET TCP server. So far I'm going good with few connections. But since I've decided to do some stress testing, I've found some problems. With a client starting threads, I get 128 successful connections, but at the 129th connections, I get:

too busy servers exception.

I've already changed maxConnections to 1000 at the binding. I've already changed maxConcurrentCalls, maxConcurrentSessions, maxConcurrentInstances to 5000 (testing only) at serviceThrottling.

My Binding:

<binding name="netTcpClientsBindingConfig" transferMode="Buffered" maxReceivedMessageSize="50242880"
    closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:05:00"
    sendTimeout="00:05:00" maxConnections="1000">

My Behavior config:

<behavior name="mexClientsBehavior">
    <serviceThrottling
        maxConcurrentCalls     = "5000"
        maxConcurrentSessions  = "5000"
        maxConcurrentInstances = "5000"
    />

I'm expecting to accept at least 1000 connections.

There is one limitation here (I believe so! Please can anyone correct me if there is another solution):

I need to retain the connection OPENED, because my server may contact the client through callbacks to send information that the clients should know about as soon as possible. If the connection is closed, I cannot re-open at the server side, or can I? That would be a solution.


Solution

  • My problem was: I was using the app.config to create the WCF TCP service.

    I've created everything again, but programmatically! Now my software has the max connections and all the Throttling needed configs. Also, now I can create the endpoints dinamically! That's a way to deploy services (windows service based) in multiple computers to load balance.

    I'm using VS 2017 15.9.11 Hope that anyone else that pass trough this king of problem get this answer.