[GH-ISSUE #186] [BUG] ConnectionResetError: [Errno 104] Connection reset by peer #31

Closed
opened 2026-02-27 08:11:31 +03:00 by kerem · 4 comments
Owner

Originally created by @staniel359 on GitHub (Apr 12, 2023).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/186

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]
Originally created by @staniel359 on GitHub (Apr 12, 2023). Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/186 **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]
kerem 2026-02-27 08:11:31 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@kokarare1212 commented on GitHub (Apr 12, 2023):

ConnectionResetError was not being handled, so I was added.
622483655c

<!-- gh-comment-id:1506019436 --> @kokarare1212 commented on GitHub (Apr 12, 2023): ConnectionResetError was not being handled, so I was added. 622483655ca90806235a85a8346f1cb925749a3e
Author
Owner

@staniel359 commented on GitHub (Apr 12, 2023):

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

<!-- gh-comment-id:1506043658 --> @staniel359 commented on GitHub (Apr 12, 2023): @kokarare1212 Good, thank you! When will the next version be released?
Author
Owner

@kokarare1212 commented on GitHub (Apr 13, 2023):

Yes, I have released it.
https://github.com/kokarare1212/librespot-python/releases/tag/v0.0.8

<!-- gh-comment-id:1506857404 --> @kokarare1212 commented on GitHub (Apr 13, 2023): Yes, I have released it. https://github.com/kokarare1212/librespot-python/releases/tag/v0.0.8
Author
Owner

@staniel359 commented on GitHub (Apr 13, 2023):

@kokarare1212 Thank you!

<!-- gh-comment-id:1506890439 --> @staniel359 commented on GitHub (Apr 13, 2023): @kokarare1212 Thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot-python-kokarare1212#31
No description provided.