question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bot not auto reconnecting

See original GitHub issue

Summary

So my bot keeps disconnecting from discord every few hours. I’m using the write so it should have automatically reconnected.

Reproduction Steps

I switched from using JSON files for server configuration to database ones(but I’m using asqlite).

Minimal Reproducible Code

Here's the log that shows it disconnecting for no reason:

2021-04-26 16:03:00,616:DEBUG:discord.client: Dispatching event socket_response
2021-04-26 16:03:00,616:DEBUG:discord.client: Dispatching event member_update
2021-04-26 16:03:02,454:INFO:discord.client: Received signal to terminate bot and event loop.
2021-04-26 16:03:02,454:INFO:discord.client: Cleaning up tasks.
2021-04-26 16:03:02,454:INFO:discord.client: Cleaning up after 2 tasks.
2021-04-26 16:03:02,454:INFO:discord.client: All tasks finished cancelling.
2021-04-26 16:03:02,455:INFO:discord.client: Closing the event loop.

Expected Results

I expected the bot to reconnect after disconnecting

Actual Results

It would just stop and never even reconnect

Intents

member and presence

System Information

Python 3.7 Discord.py 1.6.0 Raspberry PI OS on the Raspberry Pi it runs on Windows on my PC

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

I use a Raspberry Pi to keep my bot running, but this issue hasn’t happened before

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
StandingPadAnimationscommented, Apr 28, 2021

That doesn’t seem like a good idea for python programs. Plus, I don’t understand service files, despite the amount of tutorials I watched

3reactions
Kavan72commented, Apr 28, 2021

Don’t use tmux. Create service file and run as user or root whatever you like.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reconnect bot when it's kicked/disconnected #623 - GitHub
If you attempt to reconnect using the bot with less than 30 seconds between connections, an "invalid credentials" connection will be thrown. I ......
Read more >
python - Discord Bot fails to reconnect to voice chat after leaving
one of the usual causes for this is that the context is lost when the bot disconnects, so unless it's saved, it won't...
Read more >
[Python] Making a bot auto-reconnect : r/Discord_Bots - Reddit
I'm running a small bot for a server of friends locally, but my internet dcs often for a few seconds and then my...
Read more >
[Solved]-How Do I Auto Reconnect my Discord.js Bot-discord.js
A workaround I'm using is to ping the bot (HTTP GET request in my case) every 30 minutes, destroy the client and login...
Read more >
How does your company reconnect bot runners to control room?
How do you handle reconnecting bot runners to control room after a restart? Do you have a script that reconnects it? Do you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found