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 seems to silently fail when reconnecting #387

Open
Aws0mee opened this issue May 11, 2023 · 13 comments
Open

Bot seems to silently fail when reconnecting #387

Aws0mee opened this issue May 11, 2023 · 13 comments

Comments

@Aws0mee
Copy link

Aws0mee commented May 11, 2023

Just installed Discordia and Luvit recently to work on a bot, and I've been getting a strange issue. The bot will randomly go offline after a few hours and when I check the console I will see that discord requested a reconnection and the bot claims to have reconnected. However, the bot does not seem to have actually reconnected properly as it will not respond to any chat commands and appears offline in the member list.

Below are 2 examples of my console before my bot stopped responding entirely and went offline in the message list.
image

image

@Ta-noshii
Copy link
Contributor

Im not sure how to phrase this correctly, but its windows automatically freezing the command window after a bit
Use a vps or similar instead to host your bot or try running it in its own service for it

@Aws0mee
Copy link
Author

Aws0mee commented Jun 15, 2023

Im not sure how to phrase this correctly, but its windows automatically freezing the command window after a bit Use a vps or similar instead to host your bot or try running it in its own service for it

I'm not exactly sure what you're talking about. I tested to see if the script was still running and it seems like it was. I was still able to print stuff to my console locally, but the connection to discord was completely nonfunctional. Additionally, it doesn't seem to try and reconnect ever again after this bug happens meaning the bot will be completely down until I manually fix it. I added in a sort of improper fix of automatically running my script again if the bot doesn't get any commands for an hour, but this fix is suboptimal as all variables are obviously reset when the script is executed again. As for using hosting, I'm running the bot off my dedicated windows server, so I don't think using a vps would change anything at all and would only have worse performance.

@Ta-noshii
Copy link
Contributor

Have you tried disabling QuickEdit mode?

Command Prompt > Properties > Options > Quickedit

@Aws0mee
Copy link
Author

Aws0mee commented Jun 16, 2023

Have you tried disabling QuickEdit mode?

Command Prompt > Properties > Options > Quickedit

I can try, but I don't see how that would change anything in this case.

@Ta-noshii
Copy link
Contributor

Did that fix it for you?

@Aws0mee
Copy link
Author

Aws0mee commented Jun 26, 2023

Did that fix it for you?

It appears it did not work. I disabled QuickEdit mode and added a timer to print every 10 mins to make sure the bot is still running. Bot is still running, but does not respond to any command still and appears offline on discord. Something is certainly wrong with the connection as this always happens after the bot says it reconnected.

In the screenshot below the script is still running fine, but the bot appears offline on discord and does not respond to any commands.
image

@Lort533
Copy link
Contributor

Lort533 commented Jun 27, 2023

How about using WireShark to see if or when does it stop sending any data?

@Aws0mee
Copy link
Author

Aws0mee commented Jun 28, 2023

How about using WireShark to see if or when does it stop sending any data?

I mean I could use wireshark, but I have the source for everything running I might as well just add debug prints at that point. However, I recall @SinisterRectus saying he knows what the issue might be so maybe he can help us here.

@MeteorTheLizard
Copy link

I've had a similar problem which is very rare. In the two years that I've been running 4 bots, this issue only happened 5 times. Discord requests a re-connection.. and nothing happens, the bot does not re-connect and the last line in the log is just that discord requested a re-connection. The bot eventually times out on discords end, appears offline, doesn't do anything anymore, but the script is still running. The script then has to be restarted manually to resolve this problem.

@Lort533
Copy link
Contributor

Lort533 commented Jun 28, 2023

How about using WireShark to see if or when does it stop sending any data?

I mean I could use wireshark, but I have the source for everything running I might as well just add debug prints at that point. However, I recall @SinisterRectus saying he knows what the issue might be so maybe he can help us here.

I don't think that debug prints may fully help, I mean by using WireShark you are sure that Discordia does not do anything to reconnect.

@Aws0mee
Copy link
Author

Aws0mee commented Jun 29, 2023

I've had a similar problem which is very rare. In the two years that I've been running 4 bots, this issue only happened 5 times. Discord requests a re-connection.. and nothing happens, the bot does not re-connect and the last line in the log is just that discord requested a re-connection. The bot eventually times out on discords end, appears offline, doesn't do anything anymore, but the script is still running. The script then has to be restarted manually to resolve this problem.

Sounds like my exact issue, would you happen to be running your bot on windows server too?

@MeteorTheLizard
Copy link

Sounds like my exact issue, would you happen to be running your bot on windows server too?

Debian, on a pi to be exact. It's very rare, and again, the last line in the log is the "discord requested a re-connection" thing. It seems to be different to your issue as yours claims it has established a connection while mine doesn't. If I had to make a guess, I'd say that when discord requests a re-connection, and your internet cuts out in that exact moment, the script gets confused, tries to establish a connection a few times, and then just gives up, and doesn't care about your internet working again at one point. My internet resets daily and the timestamps seem to match.

@Lort533
Copy link
Contributor

Lort533 commented Jun 29, 2023

If it had connection related issues, it would show an error like EAI_AGAIN. Again, try using Wireshark to see if any type of connection is actually being made, I guess some parts of code may look good while making unexpected results.

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

No branches or pull requests

4 participants