On the local machine , Call one repeatedly with high frequency API Interface , appear “Max retries exceeded with url”, The connection is rejected .
Let's talk about , Meet this bug The process of :
In the server developed a recognition image text API Interface , Also deployed , Prepare to test the interface ,
The landlord is ready to check the 2000 Test with multiple pictures , That is to say, it needs to be called repeatedly API Interface 2000 many times .
Request interface 50 Many times , The interface will not feed back information , Report errors , Connection error , Unable to connect , At first, I thought it was a network problem , Then start calling again until it is adjusted 300 many times , Report errors , Connection error , Unable to connect , It's been like this for about seven or eight times ...
So it turns on “ use Baidu Search ”, Many tutorials are also available online , for example :
res = requests.post(url, headers=headers, json=parm, cookies=cookies)
# After the request is completed , Close the connection ( If for the same request When initiated with high frequency , There may be Max retries exceeded with url)
res.close()
# It was observed that , Close after use res.close(), Can solve Max retries exceeded with url Error of
https://www.cnblogs.com/cuitang/p/15407448.html
terms of settlement :
s=requests.session()
s.keep_alive=False
s.post(url)
https://laidefa.blog.csdn.net/article/details/102740747
# Increase the number of reconnections :
requests.DEFAULT_RETRIES = 5
s=requests.session()
# Turn off redundant connections
s.keep_alive=False
https://blog.csdn.net/llllllkkkkkooooo/article/details/107637980
headers = {
'Connection':'close'}
https://www.jianshu.com/p/afe366963379
The owners of the above schemes have tried , Didn't solve my problem ...【 The main thing is the wrong medicine , There is something wrong with the medicine , ha-ha 】
However, the landlord did not give up solving the problem , Keep looking for information !
Finally found a suitable “ drug ”, Share below :
That is to say , Just install this package :pip install pyopenssl or pip install -U pyopenssl
https://www.jianshu.com/p/5a57ad129e4b
The above content is only for personal record reference , Non standard answers
https://blog.csdn.net/weixin_45520735/article/details/115260374