HttpWebRequest times out on second call

后端 未结 8 561
猫巷女王i
猫巷女王i 2020-11-29 03:45

Why does the following code Timeout the second (and subsequent) time it is run?

The code hangs at:

using (Stream objStream = request.GetResponse().Ge         


        
8条回答
  •  旧时难觅i
    2020-11-29 04:35

    ran into the same problem with timeouts on subsequent requests to the server despite disposing/flushing/closing everything properly. try flushing your connection group, worked for me:

    myRequest.ServicePoint.CloseConnectionGroup(myRequest.ConnectionGroupName);
    

    also, ensure you're not inadvertently creating other HttpWebRequest/Request objects elsewhere in your application that aren't being properly terminated/disposed, as this will increase the numbers of connections in the Service Point.

提交回复
热议问题