Since upgrading to 4.9.0, we've been getting the following error appearing frequently in sentry:
ConnectionResetError: [Errno 104] Connection reset by peer
File "urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
# Permission is hereby granted, free of charge, to any person obtaining a copy
File "urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "http/client.py", line 1344, in getresponse
response.begin()
File "http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
File "requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "urllib3/util/retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
# Permission is hereby granted, free of charge, to any person obtaining a copy
File "urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "http/client.py", line 1344, in getresponse
response.begin()
File "http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
File "__init__.py", line 615, in _write_request
response = self._session.post(
File "requests/sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
MixpanelException: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
File "__init__.py", line 731, in _flush_endpoint
self._consumer.send(endpoint, batch_json, api_key=self._api_key)
File "__init__.py", line 594, in send
self._write_request(self._endpoints[endpoint], json_message, api_key, api_secret)
File "__init__.py", line 623, in _write_request
six.raise_from(MixpanelException(e), e)
File "<string>", line 3, in raise_from
# Permission is hereby granted, free of charge, to any person obtaining a copy
MixpanelException: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
File "/usr/src/app/./api/users/tracking.py", line 80, in _track
mixpanel_track(
File "/usr/src/app/./api/users/tracking.py", line 140, in mixpanel_track
flush()
File "/usr/src/app/./api/users/tracking.py", line 128, in flush
current_app.mp_consumer.flush()
File "__init__.py", line 722, in flush
self._flush_endpoint(endpoint)
File "__init__.py", line 736, in _flush_endpoint
six.raise_from(mp_e, orig_e)
File "<string>", line 3, in raise_from
# Permission is hereby granted, free of charge, to any person obtaining a copy
This only started after upgrading and seems to be to do with the switch the requests. It happens when we flush the consumer.