Am I able to reuse a HttpWebRequest?

前端 未结 3 543
南笙
南笙 2020-11-30 10:47

Am I able to reuse a HttpWebRequest?

It seems like the 3rd request to a site causes a operation to time out. It seems like each request creates a new connection, so

3条回答
  •  抹茶落季
    2020-11-30 11:45

    Just create a new one. I wouldn't worry about being efficient in this scenario, as the .NET environment + HTTP keepalives should handle things for you from that perspective I believe.

    Probably you're running into either 1) an issue with the number of open connections; kill the connection and the error will go away or 2) an issue with limits of number of requests per second on the server (anti-DoS stuff). I'd try #1 first, as it's simpler, and then if you still see the problem, check to see if the server is getting the request but denying it.

提交回复
热议问题