简体   繁体   中英

How to handle HttpClient Keep-Alive response header with max and timeout

HttpClient starts throwing exceptions after a few requests to a specific server. After some tests I noticed that it always stops working at request number 33. The server sends this response header:

Keep-Alive:timeout=5, max=32

I have tried to dispose HttpClient at request number 32 or less but it does not solve the problem.

How should I handle it in order to send requests without problems to this server ?

尝试调用HttpClient.Dispose或显式设置Connection: close标头

client.DefaultHeaders.Add("Connection", "close");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM