Closed Gruntwill closed 3 years ago
I haven't had any long listeners running, but my guess is you aren't sending any requests to the websocket after you've setup your listener, and so after a while the TCP connection just becomes stale.
Usually there's some sort of ping/pong implementation that's used with websockets to keep the underlying connection alive, but in the case of the Rust+ app they send requests to fetch info from the server every few moments or so, which would keep the TCP connection alive without needing another ping/pong packet.
You could try adding a timer that sends a getInfo
request or something every now and again and seeing if that solves the issue.
Also, I'm assuming the websocket isn't emitting the onclose
event, which I use to emit the disconnected
event, because the server never sent a close frame.
Let me know if this solves your issue :)
Thanks for the help! Seinding a getInfo
request every 10 seconds now and it's been going about 3 hours without issue now, I'll try it again tomorrow for longer though.
Me and a friend have been making separate bots using the library, but we've noticed it seems to disconnect after a couple of hours usually. There's no error message or crash, but it just stops picking up anything on the listeners until I restart the program or figure out a way to reconnect. I tried to implement a simple fix by listening for a disconnect but that didn't trigger either. Have you had any experience with this?
(More messages were sent after this but aren't picked up)