Skip to content

What causes the 3 hour limit? How does one close a gateway? #4

@ryanm

Description

@ryanm

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:

  1. 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?)
  2. Try a different library, like discord.js. I did that already and found the documentation confusing.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions