-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 randomly exiting process or going offline/unresponsive #8486
Comments
Having the same issue here :/ |
I still haven't found the issue, it's driving me crazy. |
Are you self hosting or is your bot running in the cloud somewhere? Asking because I have 3 bots all running the same source code, 2 run on a raspberry pi and 1 runs in repl.it. Only the one on repl is the one that gets this "Discord asked us to reconnect" debug event. |
As specified in my ticket, I've ran in multiple environments and with multiple methods, with the same result.
|
Running on Oracle Cloud with Docker, but the error also occurs on the host machine. |
Same error
|
Slightly different error. You're exiting with an error and "Authentication failed". If you check my logs there is no raised error or authentication failure. It just exits silently. I believe these are two distinct bugs. |
same |
I have been running my bot for the past 4 days without silent disconnects, it would be 7 days, but I restarted it and didn't disconnect yet, but it still has some "INTERNAL_ERRORS" in the logs. I'll keep monitoring. And btw, I moved my instance to another region, currently in UK. |
As of last night, this problem has changed - now the bot doesn't actually exit when the issue occurs. The code keeps silently running but the discord account goes offline and unresponsive. The log has slightly changed, towards the end the final event is now a
|
I have a similar issue since I upgraded to v14. After 3 to 5 days of uptime the bot goes offline with this logs :
After this, the bot is offline and there's no more log until I restart it manually. I don't know if it's related but today I also found in the logs that Discord asked for a reconnection several times :
My bot is hosted on a VPS from OVH. I'm thinking of downgrading to v13 to check if this is better. |
Having the same problem. My bot is hosted on https://railway.app and it went unresponsive after about 5 days of running. I upgraded to v14 at the same time I switched from Heroku to Railway so I'm not sure which is the cause here. My logs do log the "Discord asked us to reconnect" event every few hours, the last time it just didn't reconnect. |
So in the meantime, what can treat this issue? How can you automatically diagnose when the bot has internally disconnected from the websocket and automatically restart the process? This issue is severe and has been drastically affecting my end users. |
I have the same error, but only on my home server. Everything works as it should on my pc. But I can't leave my pc on 24/7. I have the problem since I updated to discord js version 14. I've also tried just running the login script but even then I got the same error. |
I'm experiencing the same error and I'm failing to recover it when it happens, my solution was to catch this and ask the hole server to restart, I'm running it on a VPS in Brazil, my local development server is not being affected. EDIT: I decided to go back to v13 and now it's working as expected again. |
Having this issue on another bot, nothing yet? And also, this error is not occurring on v13 |
@andrevtlopes @zLupa Which exact version of v13 are you using? I have tried it now with v13.10.3 and has still the same problem. |
try rolling back to 13.9.1 and see if it's better. |
13.8.1 |
My Findings and Pinging Test Bot@NeonWizard So to test the theory of Discord 14.x potentially having issues with stability (bots remaining online), I went and created a ping bot that uses discord 14.5.0 which pinged a discord channel every 15 minutes it was online. I also logged to the discord channel whenever the bot logged in -- and it had a setInterval to try automatically destroying the client and instantiating a new one. Here's a log of today's results, starting from 12:25 AM. You'll notice that no more than 3 pings are sent when the bot remained online (meaning it disconnected around an hour in, since 3 pings at 15 minutes each is 45 minutes). So it looks like there might be some timer that's disconnecting the bot after an hour. Redacted the bot name and tag.
I stopped gathering data at 10:11 PM. So this bot was offline for an hour after that last ping. Upon looking into the client instance, I saw something with a timeout of one hour -- going by the observation that my bot did not give more than 3 pings.
Under
When my pinging bot disconnected, on replit this is what I saw in the console:
This means that the client status was online, just that the user is null (i.e. bot is not logged in). So it's not an issue with the client instance from what I see, it's that the user (bot) is getting disconnected. And the idle timeout value of one hour looks suspicious to me considering the three 15 minute pings I was seeing at most at any given time the bot was online. Not only that, but even when my code was checking to log back in every 2 minutes, the bot could take over an hour to go online again. What a successful login looked likeWhen I was actually able to log in the bot, there were several web socket manager debug logs. I removed the other statements to focus on just the WS output.
Note: WS is WebSocketManager
Findings in ThreadSome other findings in the this thread:
The common data point seems to be that somewhere between v13.8.1 and v13.10.3, something introduced this issue of bots disconnecting from the client. And then that ended up getting into v14.x You can see the diff between v13.8.1 and v13.10.3 here: |
@Dossar That's a nice test. The Internet is wack there is no way that any connection is gonna be active 24/7. I mean there is a reason why people use TCP over UDP even tho UDP is way faster than TCP. TCP helps them get back the lost packets. I said this to show you that the internet is not 100% reliable but we found ways to make it reliable. In this case, your bot was actually connected to the Discord API and it gets disconnected and gets reconnected back and this is normal. I have a bot with 60k+ servers and we have a hell lot of interactions we have around 2-5k active users playing the bot at any given time. It's a game bot so this kind of activity is expected. Below are the logs of a successful reconnect
But there are times at which just after the above log ended the WS again sends a CLOSE event similar to the user who created this issue and it again goes through the reconnect process and reconnects. This usually takes a few minutes. But if the reconnect is taking several minutes and causing huge downtimes then it might be a bug inside of the DJS. We don't have any such issues with our bot and we are staying below v14 [13.9.1] until the To sum it up, I think DJS can only work towards better handling and reconnecting to the Discord API. We cannot control the disconnects which are caused by many reasons [Internet, Discord, etc]. |
I think this ticket is starting to deviate from my issue. In my instance (the OP), it's not reconnecting at all every now and then. Most of the time DJS handles the websocket reacquisition fine, but sometimes it doesn't and my application becomes a zombie. The bot doesn't come back online until the entire process is restarted. |
@kyranet I just wanted the fixes to be tested before I submitted the pr. That's the only reason I asked them to use my |
On my side, I have good results with the combination of :
I think @legendhimself's Pull Request could now be submitted. The current default value is more than reasonable for small bots, but becomes unsustainable for slightly larger bots (or ratio too low). It seems that the amount of data received also affects this ratio as if the Discord API puts the data to be sent to you in a global queue, and they are limited by how much they can send you in X amount of time which would make us receive the heartbeats later and therefore need more time before defining a shard connection as zombie. I had observed that I was having a lot more trouble receiving GUILD_MEMBERS_CHUNK after a global fetch of members with presence intent enabled. This could potentially be related to this. |
Got a report stating the linked pull request didn't resolve the issue. Feel free to open a pull request @legendhimself and we'll see how things go from there. |
doesn't solved for me |
There was discord related issue today which caused many shards to go into a zombie connection which automatically got reconnected for us, There was no process exits though. What about you,? Please provide logs so we can try to patch it for time being if there is any. |
i would be happy to provide logs but nothing happens, day after day, shard sends his heartbeat for the last time and so on a new |
okay, I couldn't understand what you are trying to say but logs can give a rough idea of whats happening. |
|
interesting. |
I started getting exits with status 0 today which are classified by systemctl as service success, after 3-5 days of running the bot with no visible disconnections. This is discouraging. |
I was having both of those issues (exiting with status code 0 and going zombie mode) when I originally created this ticket. I think this should be reopened and revisited. |
Sorry for misunderstanding, I didn't have the zombie mode process issue yet (at least not that I know of, the bot isn't actively used), I was just refering the above. |
Got same error there, shards exit silently after a certain time and the application stop responding to interaction (djs v14) |
This is a really old issue and was fixed for v13. You might need to create a new issue similar to this for v14. |
This issue was for discord v14. I'm still not sure why it's closed. |
We fixed it for v14 and backported it for v13. The current v14 uses the new |
You submitted the bug report for v14, please open a separate issue for v13 if the issue persists there. Also, as pointed out, the entire gateway implementation has been switched out, so there's pretty much no way this is relevant anymore even for v14. |
Which package is this bug report for?
discord.js
Issue description
After around 5-6 hours of running, my discord bot decides to randomly exit with an exit code of 0. There is nothing in my code that should cause that, and adding a debug event listener shows the bot failing around a websocket reacquisition near the 6 hour mark.
I have tried running my bot with typescript, I've tried compiling the code to javascript and running that, I've tried packaging it as a docker container and running that locally, I've tried packing it as a docker container and running that on my production server. Every environment and method results in the same issue.
Bot code
https://github.com/NeonWizard/sockbot-discord
Logs
Code sample
https://github.com/NeonWizard/sockbot-discord
Package version
discord.js@14.1.2
Node.js version
v16.16.0, typescript@4.7.4
Operating system
Windows (WSL), Linux (Ubuntu), Docker (node:lts-alpine)
Priority this issue should have
High (immediate attention needed)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildMessages, GuildMessageReactions, MessageContent
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: