Multiple http-requests are stuck
I have a problem with multiple tcp (http) connections on Windows. When my program sent many (says, 300 http-connections. The critical number of http-connections depends on speed of Internet connection) http-requests, part of them are stuck. That means, request is sent, but response is either received partly or not received at all. At that, a stuck connection isn’t dropped by web server.
This problem is present only in the Internet. There is no such problem on local machine. Based on experiment, the problem doesn’t depend on either my application sends all 300 requests to single web server or my app sends requests, says, to 6 servers by 50 requests to each server. The result is the same: some of connections are stuck for a long time.
I made a small program to investigate this problem. The program sends http-requests and receives http-response. The program creates the thread for each connection. There is opportunity to set timeout between creating connections. By default, there is no timeout and all connections are created at the same time. When I was playing with this app, I found that if I set the timeout (10-100 millisecond), http-requests worked more effectively. Sometimes, if to choose the right timeout, there are no stuck and the app uses almost all available bandwidth.
Can somebody write what’s the problem? Why are requests are stuck? What’s the cause? I could send the test app with source codes (c++) by request.