Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MastodonNetworkError: Server ceased communication when mastodon.stream_user(rl) #1

Open
melocery opened this issue Jul 25, 2022 · 0 comments

Comments

@melocery
Copy link

Hi! I use the template, 'reply.py', as a part of my auto-reply bot.
Everything goes well, but when I use the code as follow:

  class ReplyListener(StreamListener):
      def on_notification(self, notification): #listen for notifications
          if notification['type'] == 'mention': #if we're mentioned:
              process_mention(mastodon, notification)
  
  # create a new instance of our ReplyListener class
  rl = ReplyListener()
  mastodon.stream_user(rl) #go!

I got the error:

Traceback (most recent call last):
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 700, 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 "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 441, in _error_catcher
    yield
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 767, in read_chunked
    self._update_chunk_length()
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 704, in _update_chunk_length
    raise InvalidChunkLength(self, line)
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\models.py", line 760, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 575, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 796, in read_chunked
    self._original_response.close()
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\response.py", line 458, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\mastodon\streaming.py", line 64, in handle_stream
    for chunk in response.iter_content(chunk_size = 1):
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\models.py", line 763, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

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

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\mastodon\Mastodon.py", line 102, in wrapper
    return function(self, *args, **kwargs)
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\mastodon\Mastodon.py", line 3110, in stream_user
    return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\mastodon\Mastodon.py", line 3628, in __stream
    listener.handle_stream(r)
  File "C:\Users\geron\AppData\Local\Programs\Python\Python36\lib\site-packages\mastodon\streaming.py", line 91, in handle_stream
    err
  File "<string>", line 3, in raise_from
mastodon.Mastodon.MastodonNetworkError: Server ceased communication.

Is it because that the instance configeration of my bot or anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant