ProxyError while running my python script

Hi ,

I am running a python script which is working fine locally. But from a remote machine where the proxy is enabled (os.environ[‘HTTPS_PROXY’], os.environ[‘HTTP_PROXY’]), the script work fine for some duration but after some time. It throws a ProxyError as follows. Any suggestions to resolve this?

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='MY_Application_Hostname_goes_here', port=443): Max retries exceeded with url: /services/data/v50.0/query/?q=SELECT+..... (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer')))

requests.exceptions.ProxyError: HTTPSConnectionPool(host='MY_Application_Hostname_goes_here', port=443): Max retries exceeded with url: /services/data/v50.0/query/?q=SELECT...... (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer')))

When we checked the proxy log, It shows “TCP_TUNNEL_ABORTED” which states the connection is being closed by the client. So it is not from server end.

At face value this means the proxy reset the tcp connect.
That would seem to indicate a problem with the proxy.
Does it have a max connection limit that you are hitting?

@Barrry Thanks for your reply, I am running a single user hitting 2 requests per sec. When you say max connection limit, is it from python config level or the application(this doesn’t have any limit- i understand the limit is in terms of 2gbps which is high)?

It is the server that has the problem not the python code as far as i can guess.
I am assuming that reset that is in the error message is the rst tcp ip packet sent from the server.

Would you mind telling me the exact line where it tells the rest TCP IP packet sent from the servers. I am new to this kind of error. Sorry again to ask if this is layman question.

[squid-users] TCP_TUNNEL_ABORTED/200? → When i check the status from the logs it is TCP_TUNNEL_ABORTED and its summary is provided in this link.

The below IP will be different in my case. Tried both approaches.
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:8080'
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:8080'

os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:8080'
os.environ['HTTP_PROXY'] = 'https://127.0.0.1:8080'

I’m assuming that is what this error means. (peer == server)
To be sure you would need to run wireshark and capture the packets to see the detail of the TCP echange.