kokarare1212/librespot-python

[BUG] ConnectionResetError: [Errno 104] Connection reset by peer

staniel359 opened this issue ยท 4 comments

Describe the bug
I run your program on a Flask server, so it's running constantly.
And once in a while I get this error:

Apr 12 17:28:25 muffon waitress-serve[1438302]: Exception in thread session-packet-receiver:
Apr 12 17:28:25 muffon waitress-serve[1438302]: Traceback (most recent call last):
Apr 12 17:28:25 muffon waitress-serve[1438302]:   File "/usr/local/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
Apr 12 17:28:25 muffon waitress-serve[1438302]:     self.run()
Apr 12 17:28:25 muffon waitress-serve[1438302]:   File "/usr/local/lib/python3.10/threading.py", line 946, in run
Apr 12 17:28:25 muffon waitress-serve[1438302]:     self._target(*self._args, **self._kwargs)
Apr 12 17:28:25 muffon waitress-serve[1438302]:   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 1632, in run
Apr 12 17:28:25 muffon waitress-serve[1438302]:     packet = self.__session.cipher_pair.receive_encoded(
Apr 12 17:28:25 muffon waitress-serve[1438302]:   File "/usr/local/lib/python3.10/site-packages/librespot/crypto.py", line 58, in receive_encoded
Apr 12 17:28:25 muffon waitress-serve[1438302]:     header_bytes = self.__receive_cipher.decrypt(connection.read(3))
Apr 12 17:28:25 muffon waitress-serve[1438302]:   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 1536, in read
Apr 12 17:28:25 muffon waitress-serve[1438302]:     return self.__socket.recv(length)
Apr 12 17:28:25 muffon waitress-serve[1438302]: ConnectionResetError: [Errno 104] Connection reset by peer

And then the program stops working.
I try to handle the error, but it doesn't seem to be handled.
Could you improve this connection reset logic?

To Reproduce

  1. Create Session
  2. Get it running constantly
  3. Call session.content_feeder().load() for days
  4. One day it returns an error and stops working

Expected behavior
I expect this error to be handled and connection to be restored.

Client Information (please complete the following information):

  • OS: Debian 11
  • Python Version [3.10.2]
  • Library Version [0.0.7]

ConnectionResetError was not being handled, so I was added.
6224836

@kokarare1212 Good, thank you!
When will the next version be released?

@kokarare1212 Thank you!