OSError Connection broken happening frequently
See original GitHub issueOS: ubuntu 14.04 python: 3.5.2 tweepy: 3.6.0
I’m using stream.filter and I periodically get a connection reset/broken error that forces me to restart my application. This happens a couple times a day, sometimes every 10 minutes or so. How should I handle this error and is there anything I can do to prevent it? Stack trace:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/OpenSSL/SSL.py", line 1814, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/home/ubuntu/.local/lib/python3.5/site-packages/OpenSSL/SSL.py", line 1614, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/OpenSSL/SSL.py", line 1814, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/home/ubuntu/.local/lib/python3.5/site-packages/OpenSSL/SSL.py", line 1631, in _raise_ssl_error
raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (104, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/response.py", line 331, in _error_catcher
yield
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/response.py", line 413, in read
data = self._fp.read(amt)
File "/usr/lib/python3.5/http/client.py", line 448, in read
n = self.readinto(b)
File "/usr/lib/python3.5/http/client.py", line 478, in readinto
return self._readinto_chunked(b)
File "/usr/lib/python3.5/http/client.py", line 573, in _readinto_chunked
chunk_left = self._get_chunk_left()
File "/usr/lib/python3.5/http/client.py", line 541, in _get_chunk_left
chunk_left = self._read_next_chunk_size()
File "/usr/lib/python3.5/http/client.py", line 501, in _read_next_chunk_size
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python3.5/socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 300, in recv_into
return self.recv_into(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 290, in recv_into
raise SocketError(str(e))
OSError: (104, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/package/services/check_twitter.py", line 195, in main
stream.filter(follow=list(extractors.keys()))
File "/home/ubuntu/.local/lib/python3.5/site-packages/tweepy/streaming.py", line 450, in filter
self._start(async)
File "/home/ubuntu/.local/lib/python3.5/site-packages/tweepy/streaming.py", line 364, in _start
self._run()
File "/home/ubuntu/.local/lib/python3.5/site-packages/tweepy/streaming.py", line 297, in _run
six.reraise(*exc_info)
File "/home/ubuntu/.local/lib/python3.5/site-packages/six.py", line 693, in reraise
raise value
File "/home/ubuntu/.local/lib/python3.5/site-packages/tweepy/streaming.py", line 266, in _run
self._read_loop(resp)
File "/home/ubuntu/.local/lib/python3.5/site-packages/tweepy/streaming.py", line 316, in _read_loop
line = buf.read_line().strip()
File "/home/ubuntu/.local/lib/python3.5/site-packages/tweepy/streaming.py", line 181, in read_line
self._buffer += self._stream.read(self._chunk_size)
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/response.py", line 430, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/response.py", line 349, in _error_catcher
raise ProtocolError('Connection broken: %r' % e, e)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
"chunkedEncodingError, Connection broken: OSError 104 ...
Maybe I am querying from BigQuery, or inserting into MongoDB, too frequently? Here is the full error from the Airflow logs: [2020-07-29 22 ......
Read more >gogrepo.py - Python script for regularly backing up your ...
ChunkedEncodingError: ('Connection broken: OSError("(104, ... This error happens for every single file just before it is downloaded.
Read more >Application, ER and HDR network failures occurring frequently ...
Problem. Frequent disconnections of applications, replication processes within IBM Informix Servers, or remote database connections, with either ...
Read more >Troubleshooting Connection Issues - MariaDB Knowledge Base
There are a number of common problems that can occur when connecting to MariaDB. Server Not Running in Specified Location. If the error...
Read more >Cannot upload local files to AzureML datastore (python SDK)
What happens is that the program starts to upload the file, ... status=None)) after connection broken by 'ProtocolError('Connection aborted.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is Twitter’s API closing the connection with a TCP/IP reset (RST).
Your traceback is missing the key final exception that’s raised, but it seems to be a
urllib3.exceptions.ProtocolError
, which should now be handled by Tweepy with https://github.com/tweepy/tweepy/commit/68e19cc6b9b23d72369ca1520093770eb18a5a9f.As for preventing the issue, see Twitter’s documentation on disconnections when consuming streaming data.
@ghost This is a different error using a different method/endpoint. It’s unrelated to this issue, but feel free to make a new issue.
I’m getting same error. Handle it by catching it in a try except block example.
Not sure how to prevent it or what exactly causes the error. Maybe the fault is entirely with the Twitter API.