As others have said, gateways have a lifespan of (roughly) 3 hours. After that they stop working. The stream ends.
What causes the gateway connection to silently fail?
Hypothesis: The token has expired. (False.) If I restart my node app, the token works again.
How do I detect when a failure occurs?
Hypothesis: If I wrap gateway.on('message', callback) in a try-catch it might throw an error. I will try that.
In any case, I see 3 options:
- Start a new instance of selfcore every 2 hours or so. (But how do I close running connections? It doesn't appear that's possible in selfcore today. I would have to restart the entire node app every 2 hours, which I could do. But would that politely close the connection, or would the connection stay open?)
- Try a different library, like discord.js. I did that already and found the documentation confusing.
- Fork this repo. Research & fix the bug. (I read the code but don't understand it. So I put a high estimate (20 hours) on this approach.)
All I want: To fetch messages from a public discord channel that I do not admin. Selfcore provides the real-time stream, and I figured I would hunt for another library to do one-time downloads.
Any guidance would be greatly appreciated.
As others have said, gateways have a lifespan of (roughly) 3 hours. After that they stop working. The stream ends.
What causes the gateway connection to silently fail?
Hypothesis: The token has expired. (False.) If I restart my node app, the token works again.
How do I detect when a failure occurs?
Hypothesis: If I wrap
gateway.on('message', callback)in a try-catch it might throw an error. I will try that.In any case, I see 3 options:
All I want: To fetch messages from a public discord channel that I do not admin. Selfcore provides the real-time stream, and I figured I would hunt for another library to do one-time downloads.
Any guidance would be greatly appreciated.