Broken streaming connection

I’m having weird issue with streaming service.

When I connect to streaming api, it works well at the moment but with extended period time of usage, streaming timeline gives me this error.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 572, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 331, in _error_catcher
    yield
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 637, in read_chunked
    self._update_chunk_length()
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 576, in _update_chunk_length
    raise httplib.IncompleteRead(line)
http.client.IncompleteRead: IncompleteRead(0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 749, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 461, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 665, in read_chunked
    self._original_response.close()
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.7/site-packages/urllib3/response.py", line 349, in _error_catcher
    raise ProtocolError('Connection broken: %r' % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/mastodon/streaming.py", line 59, in handle_stream
    for chunk in response.iter_content(chunk_size = 1):
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 752, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/site-packages/mastodon/Mastodon.py", line 2360, in _threadproc
    raise e
  File "/usr/local/lib/python3.7/site-packages/mastodon/Mastodon.py", line 2357, in _threadproc
    listener.handle_stream(r)
  File "/usr/local/lib/python3.7/site-packages/mastodon/streaming.py", line 84, in handle_stream
    err
  File "<string>", line 3, in raise_from
mastodon.Mastodon.MastodonNetworkError: Server ceased communication.

Since it’s not happening on other instance, I presume there’s something wrong with my instance configuration, but I have no clue where to begin with. Any advice would be appreciated.

Do you see anything in the output of your node process running the streaming service?

Now you mentioned it, I looked up the log with journalctl| grep -i streaming and found this keep occuring

Mar 06 10:55:33 canors_ubuntu systemd[20166]: mastodon-streaming.service: Changing to the requested working directory failed: No such file or directory
Mar 06 10:55:33 canors_ubuntu systemd[20166]: mastodon-streaming.service: Failed at step CHDIR spawning /usr/bin/npm: No such file or directory
Mar 06 10:55:33 canors_ubuntu systemd[1]: mastodon-streaming.service: Main process exited, code=exited, status=200/CHDIR
Mar 06 10:55:33 canors_ubuntu systemd[1]: mastodon-streaming.service: Failed with result 'exit-code'.
Mar 06 10:55:33 canors_ubuntu systemd[1]: mastodon-streaming.service: Service hold-off time over, scheduling restart.
Mar 06 10:55:33 canors_ubuntu systemd[1]: mastodon-streaming.service: Scheduled restart job, restart counter is at 10.

and when I ls /usr/bin/npm

canor@canors_ubuntu:/var/www/html/blog$ ls /usr/bin/npm
lrwxrwxrwx 1 root root 38 Feb 28 16:12 /usr/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js

any idea? thanks.

I’d try to solve this problem first. There is some non-existing directory in your unit file.

1 Like