mandrewcito / signalrcore

SignalR Core python client
https://mandrewcito.github.io/signalrcore/
MIT License
119 stars 57 forks source link

Reconnect logic spamming logs and creating threads until resource exhaustion occurs #97

Open dcmeglio opened 1 year ago

dcmeglio commented 1 year ago

Describe the bug It seems to be if a disconnect happens, my logs flood with: Connection closed Connection is already closed

It happens dozens of times a second until it seems my app just crashes and restarts. Note that each log entry has a different thread id. It seems you're spawning threads until things run out.

To Reproduce Steps to reproduce the behavior:

  1. Let a disconnect error occur.

Expected behavior The reconnect logic shouldn't be cause the process to die. Also my reconnect interval is set to 5s which doesn't seem to be respected

Screenshots 2022-12-24 13:52:43.497 WARNING (Thread-93786 (deferred_reconnect)) [SignalRCoreClient] Connection closed Connection is already closed. 2022-12-24 13:52:43.509 WARNING (Thread-93787 (deferred_reconnect)) [SignalRCoreClient] Connection closed Connection is already closed. 2022-12-24 13:52:43.523 ERROR (Thread-93530 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.533 ERROR (Thread-93534 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.540 ERROR (Thread-93535 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.550 WARNING (Thread-93788 (deferred_reconnect)) [SignalRCoreClient] Connection closed Connection is already closed. 2022-12-24 13:52:43.556 WARNING (Thread-93789 (deferred_reconnect)) [SignalRCoreClient] Connection closed Connection is already closed. 2022-12-24 13:52:43.575 WARNING (Thread-93790 (deferred_reconnect)) [SignalRCoreClient] Connection closed Connection is already closed. 2022-12-24 13:52:43.590 ERROR (Thread-93536 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.598 ERROR (Thread-93538 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.604 ERROR (Thread-93533 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.653 ERROR (Thread-93537 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.671 ERROR (Thread-93540 (deferred_reconnect)) [SignalRCoreClient] 2022-12-24 13:52:43.676 WARNING (Thread-93791 (deferred_reconnect)) [SignalRCoreClient] Connection closed Connection is already closed.

Desktop (please complete the following information):

Additional context Edit: I'm rather confused by how this library is supposed to work. You launch run_forever in a thread, but run_forever creates a thread already. The thread you create is never joined, yet on a reconnect, you create a new thread. So the old thread, I think, lives forever? So during a reconnect loop I'd expect we'd just be creating thread after thread, right?

SipanOhanyan commented 1 week ago

It will be fixed after #114 pull request merge.