What limit my connections?

I set the maxConnections of my netTcpBinding to 1000, and the behaviorConfiguration of my service is like this:

    <BEHAVIOR name="SampleServiceBehavior">
     <SERVICETHROTTLING maxConcurrentInstances="1000" maxConcurrentSessions="1000" maxConcurrentCalls="1000" />
    </BEHAVIOR>

In my client, I send 200 requests to my service in 200 threads, In every thread, I create a new proxy to connect to my service. In my service, I make the thread sleep 10 seconds before return the response. for I want to simulate multiple clients call the service to do a long time work in concurrency. But I found that my client can't receive all the responses. And there were some timeout exceptions(It should be EndpointNotFoundException).

I think all of the 200 requests will be sent to the service, and after 10 seconds, all of the 200 responses will be received by the client, But this isn't the fact. How can I do to achieve this




Answer this question

What limit my connections?

  • selva_kumar

    Hi, Madhu

    I've sent you my test code, hope you can help me.

    I think my problem is caused by the instancing behavour of WCF. If I send 1000 requests to my service concurrently at the begining, an EndpointNotFound exception will be gotten (Test_1); If I send 10 requests, and then send 15 requests, and then send 20 requests, and so on... It's OK(Test_3).

    Wait for a moment, My Test_3 sometimes still give me an EndpointNotFoundException.

    I do not know what is the real reason.

    I must sleep now, I'm in China :)



  • Billr17

    I think I'd better past my code:

    My bingding is:

          <netTcpBinding>
            <binding name="NewBinding0" maxBufferPoolSize="52428800" maxBufferSize="6553600"
              maxConnections="1000" maxReceivedMessageSize="6553600" />
          </netTcpBinding>

    My service behavior is:

            <behavior name="ConcurrentBehavior">
              <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000"
                maxConcurrentInstances="1000" />
            </behavior>

    Service code:

        class MyService : IMyContract
        {
            public string ExecuteService(string message)
            {
                string request = message;
                Console.WriteLine("Received Message: " + request);
                Thread.Sleep(5000);
                string response = message + "_tail";
                Console.WriteLine("Sent Message: " + response);
                return response;
            }
        }

    Client code:

            static void Test_1()
            {
                Console.WriteLine("Test_1: Press <Enter> to begin.");
                Console.Read();

                for (int i = 0; i < 1000; i++)
                {
                    Thread thread = new Thread(new ParameterizedThreadStart(DoWork_1));
                    thread.Start(i);
                }
            }

            static void DoWork_1(object param)
            {
                int num = (int)param;
                string request = "test" + num.ToString();
                Console.WriteLine(request);

                MyContractClient proxy = new MyContractClient();
                proxy.Open(); // After receive some response from service, this sentence will lead an EndpointNotFoundException.
                string response = proxy.ExecuteService(request);
                proxy.Close();

                Console.WriteLine(response);
            }



  • wpdehn

    Hi, Madhu

    I've sent you another Email, hope it is lucky this time.



  • FM_AX

    Thanks for your explanation of MaxPendingConnections. It's very useful for me. but I've set the maxConnections property of my netTcpBinding, and it's useless.

  • Ultrawhack

    What is your ConcurrencyMode and InstanceContextMode Also can you try increasing the MaxPendingAccept on the binding.

    You can do that with the following piece of code.

    NetTcpBinding tcpBinding.

    tcpBinding.Elements.Find<TcpTransportBindingElement>().MaxPendingAccepts = 1000;

    Maheshwar Jayaraman[MSFT]



  • AsifHameed1

    i just want to let you know,I didn't get repro code from you yet.

    -Thank you

    Madhu



  • Tonton888

    If you interest my question, please download my code here. waiting for your help.

  • rt_ak1949

    Hello,do you solve the problem and how



  • scyle

    MaxPendingConnections controls how many connections we’ve accepted but haven’t been picked up by the ServiceModel Dispatcher. So the timeout you are seeing could be due to the fact that the server's listener was not even ready to accept the connection. Once accepted it will then be pulled in by ServiceModel if it has any throttles left. This is a throttling knob so that we don’t just keep accepting new connections and blow your app’s memory.

    The change should go in the Server code.

    If you are using standard NetTcpBinding then you can set the MaxConnections property on that binding and it should also set the MaxPendingConnections. If you are using a custom binding then you need to do it theway I showed you in my earlier reply.

    Maheshwar Jayaraman [MSFT]



  • Residual Logic Games

    Hi, mahjayar

    I didn't set the ConcurrencyMode and InstanceContextMode, Just now I set the ConcurrencyMode to Multiple and InstanceContextMode to PerCall, there is no use.

    And I can't understand your code to increase the MaxPendindAccept. Could you show me more clearly Thanks.

    I try to implement the service in async mode (use Begin/End pattern on service side), and client can receive more responses, but it can't reach 200 also.



  • tonn

    Hi Ray,

    If you have repro for this problem,can you please send it to me,it will help to solve this problem ASAP,my email id is madhup@microsoft.com

    -Thank you

    Madhu



  • What limit my connections?