Reputation: 73
I am running into an issue where I am getting a generic remote end closed connection error:
Remote end closed connection without response
when using Python 3.5 and the requests module.
Here is an example of the code - but i'm not using any kwargs at the moment:
response = self._requests_session.get(self._nextUri, **self._requests_kwargs)
Here is the full error:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1213, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 276, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/usr/local/lib/python3.5/dist-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.5/dist-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1213, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 276, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
I am wondering what sort of additional code I add to get more information about this error or to make the connection more resilient.
I have tried taking a TCPDump capture of this issue but i'm not having anything stick out after reviewing, I am looking for some high level detail that I can get from Python or some additional things I can do to make the session more resilient.
Upvotes: 1
Views: 3241
Reputation: 73
The issue turned out to be an issue with EKS and Kubernetes.
The issue was that there seemed to be a port collision with SNAT which caused these unexpected connection errors.
It's well documented here and here:
The solution was to upgrade to Kubernetes 1.15 and adding the CNI var below:
AWS_VPC_K8S_CNI_RANDOMIZESNAT=prng
Upvotes: 1