Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot connected to Discord more than 1000 times within a short time period. #3353

Open
2 tasks
auyylaso opened this issue Nov 2, 2024 · 5 comments
Open
2 tasks

Comments

@auyylaso
Copy link

auyylaso commented Nov 2, 2024

Is your feature request related to a problem? Please elaborate.

Bot connected to Discord more than 1000 times within a short time period. PM2 will forever just keep spinning back up the bot without any care about the past issue.

Describe the solution you'd like

This is more so just a heads up but the bot has no stop point and will forever keep trying to reconnect even if the mongodb database is down causing the token to get revoked. There really should be some sort of pause if there is a error log preventing connection to mongodb otherwise PM2 May forever keep spinning it back up and causing it to timeout every 30 seconds.

Does your solution involve any of the following?

  • Logviewer
  • New config option

Describe alternatives you've considered

Turning back on my mongodb server and just resetting my token and accepting it lmfao
The other option instead of adding a check for past timeout reason is to check for mongodb before contacting discord servers as if there is no DB no need to contact discord as the bot will restart on timeout.

Who will this benefit?

Dumbasses like me who deploy everything at home and when there power goes out and forget to spin back up the DB lol

Additional Information

No response

@martinbndr
Copy link
Contributor

Can you show the bot logs please? (?debug hastebin)

@martinbndr
Copy link
Contributor

Just wanna see which error is getting raised causing your reconnect problem. So you can just share the link provided by the bot.

@auyylaso
Copy link
Author

auyylaso commented Nov 2, 2024

2024-11-02 00:00:20 core.models[324] - INFO: Discord logging level: INFO.
2024-11-02 00:00:20 main[165] - INFO: -------------------------
2024-11-02 00:00:20 main[166] - INFO: ┌┬┐┌─┐┌┬┐┌┬┐┌─┐┬┬
2024-11-02 00:00:20 main[167] - INFO: ││││ │ │││││├─┤││
2024-11-02 00:00:20 main[168] - INFO: ┴ ┴└─┘─┴┘┴ ┴┴ ┴┴┴─┘
2024-11-02 00:00:20 main[169] - INFO: v4.1.0
2024-11-02 00:00:20 main[170] - INFO: Authors: kyb3r, fourjr, Taaku18
2024-11-02 00:00:20 main[171] - INFO: -------------------------
2024-11-02 00:00:20 main[172] - INFO: discord.py: v2.3.2
2024-11-02 00:00:20 main[173] - INFO: -------------------------
2024-11-02 00:00:20 main[218] - INFO: Starting bot without presence intent.
2024-11-02 00:00:20 discord.client[603] - INFO: logging in using static token
2024-11-02 00:00:21 discord.gateway[561] - INFO: Shard ID None has connected to Gateway (Session ID: 85cce5c86138cd34e506955415664dd6).
2024-11-02 00:00:51 core.clients[487] - CRITICAL: Something went wrong while connecting to the database.
2024-11-02 00:00:51 core.clients[489] - CRITICAL: ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 6725a3d582f785b4f999f268, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
2024-11-02 00:00:51 core.clients[506] - CRITICAL: This may have been caused by not whitelisting IPs correctly. Make sure to whitelist all IPs (0.0.0.0/0) https://i.imgur.com/mILuQ5U.png
2024-11-02 00:00:51 main[270] - INFO: Cleaning up tasks.
2024-11-02 00:00:51 main[276] - INFO: Closing the event loop.

I don't run NPM or Nodejs modules on reboot just to avoid exploits so that's why this is an issue as this program is looking for services that I don't have setup to auto for example mongodb this is my own insanity but it would just be nice to not have the bot contact discord before mongodb

@raidensakura
Copy link
Member

PM2 supports (exponential) restart delay and max_restart, a bit of of a solution to a different problem scenario when the issue is less about the bot connecting to Discord before the DB and more about the process manager restarting the app many times a second when a cooldown (or attempt limit) can be added.

Plus, even if we check the DB before connecting to Discord, it still won't change the fact your app will restart many times a second without the delay so it's already counter intuitive to implement this in your case.

^But this is just my opinion, the devs may disagree

@auyylaso
Copy link
Author

auyylaso commented Nov 2, 2024

PM2 supports (exponential) restart delay and max_restart, a bit of of a solution to a different problem scenario when the issue is less about the bot connecting to Discord before the DB and more about the process manager restarting the app many times a second when a cooldown (or attempt limit) can be added.

Plus, even if we check the DB before connecting to Discord, it still won't change the fact your app will restart many times a second without the delay so it's already counter intuitive to implement this in your case.

^But this is just my opinion, the devs may disagree

You're right it's not needed nor is it a bug but it still would be nice to have a check to just to ensure if there is an issue that it won't continue to allow pm2 to hammer discords server. And yes pm2 is delayed it just doesn't matter when I have no clue there is an issue because the bot goes online before it connects to mongodb

Other solution would be if there is a way to have the bot send a message in discord that there was an issue starting. If this is already a feature lmk so I can enable it lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants