-
-
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 still silently disconnecting #1233
Comments
autoreconnect isn't a thing anymore, it is always true, no matter what you do. can you log disconnect events? i suspect you are getting close code 1000. it is also worth mentioning that being online/offline happens on the websocket gateway and sending messages happens via the http api. |
That makes sense, thanks.
Ok, didn't realize that. I'll log the disconnects and report back. Also, for what it's worth the bot is hosted on AWS. I'm not sure if that's relevant to the issue. |
Happens to me too a lot, out of nowhere for no reason. |
Hi, which version of discord.js are you guys running? |
I'm having the same issue, I'm running discord.js version 11.0.0 |
You guys need to give us some logs. But a detailed report would be kinda nice, does it come back online? What are the close codes? etc. |
In my case after being idle for a while it just says that it was disconnected, (I use the disconnect event to catch it). In that event I have a rejoin command but it when I try to play again, nothing plays(shows that it plays but no sound), and I have to reboot it for it to work normally. |
@Georgia10 but its kinda hacky in its implementation |
|
I believe I'm experiencing the same issue. The only thing printed to my "err.log" file is-
but not sure if this is related to the issue |
that error is from snoowrap, which has nothing to do with discord.js |
Same thing is happening to me every few days, close code 1000, no reason specified, then the bot never tries to reconnect. This seems to be intentional behavior; WebSocketManager has the line
I imagine this is related to https://discordapp.com/developers/docs/topics/gateway#connecting, though I don't know what 1000 means in this case and why that would prevent the bot from trying to reconnect. Here is my event log for the disconnection event. Happy to add more logging if required.
No errors/unresolved promises in the logs. |
this is a thing multiple libs and users have been seeing. can you do me a favor and on the computer that hosts your code get |
loc=GB |
thx |
I have been receiving the same over the past few days. I'll keep a look out for if it happens more often (and if the code is the same each time) and then report back the error it outputs. loc=DE Edit: Oops, these are off of my local machine. My bad, see post below. |
I'm pretty sure it's an actual coding issue instead because it has happened to a friend of mine and we have fixed his issues. |
@eaaliprantis Would you mind describing (or preferably showing) how you did that? |
@robflop Pretty much, my friend had an issue with a logging feature that he build. Whenever the bot joined a new guild, it caused an error stating that "a logger was undefined" but it wasn't a D.js issue but his code. When we resolved that issue, he has not had any 1006/1007 issues anymore. |
@eaaliprantis Hmm I see. Thanks for the input, i'll keep it in mind. |
Alright, I've been watching for a while and I always get this error:
|
@robflop thx for reporting, can you perform a |
loc=LT & colo=FRA on my vps. |
I've been getting a similar if slightly different issue for as long as I can remember - occasionally when my bot disconnects, it simply stops trying to reconnect. Not sure if this is caused by the same problem or not, but as this is causing issues with some very mission-critical elements of one of my servers, I'd really like to figure out what's going on. All the pull requests on it have been closed as fixed, but it still happens. |
@tripl3dogdare you using uws? It sounds like you are, uws has that issue... |
@tripl3dogdare can you log disconnect codes, and if it is |
Hi, I have been looking into this issue: This is potentially caused by you blocking the event loop, and preventing d.js from acking received heartbeats. This has been a known method to cause a known cloudflare bug to incorrectly respond close code 1000. (although this isn't the only way the bug can be triggered, this is one way that can be replicated in any library that can have it's event loop blocked.) Although yes, it is a bugged reason to receive the 1000. It is something we still must honor, regardless of the reason. Your solution of client.destroy()/client.login() in combination with reducing the amount of time the event loop is blocked (async methods are your friend) will be the best course until cloudflare fixes their bug. |
I've also used that fix, and its fine, but it's a little worrying as it will conflict if any changes are made based on this issue. I acknowledge its really a bug somewhere between cloudflare and discord itself, causing these extra code 1000/1006 with no reasons, but it would be nice if discord.js could mitigate it somehow, considering the issue seems to have been around for at least 10 months now, maybe longer, presumably ever since the bot api was created. Fair enough if you consider it out of scope though. @bdistin I have looked into that myself and it seems as though in my case the heartbeats are being sent on time unfortunately. |
Out of curiousity, when this happens are any of you able to check the |
I'll implement a check and see when it next happens. |
@JMTK Alright, so I just peeked into my logs and it returns a 5 on disconnect. |
I get this too
here is https://discordapp.com/cdn-cgi/trace
|
@meldsza that has nothing to do with this issue |
@meldsza u prob have an unhandledRejection / uncaughtException going through a sendMessage event, thats where i see that alot |
Having a similar issue with my bot - It's been disconnected every 2-3 days.
From the trace:
|
@idivait Do you have the full trace, including the As suggested above, it's either an unhandled Promise rejection (common) or a connectivity issue with your bot. |
@elithrar I screwed up and put the wrong trace anyhow (I've been using dokku to deploy and mistakenly did the trace on my VM rather than my server):
I also went through my code and made certain I was properly rejecting all Promises... If that ends up resolving (no pun intended) the issue, I'll post here. May take a few days, as it's generally a day or two before the disconnect happens. |
I have reviewed the RFC relating to websockets and there is one point that seems relevant to this issue: https://tools.ietf.org/html/rfc6455#section-7.3 Basically it's saying that whilst the client should not arbitrarily close the websocket, the server may. Also, section 7.4 states that the codes are optional and the interpretation of the reason is left undefined. This implies that receiving an unexpected 1000 close from the server is within spec of the RFC and that it's up the client to determine the course of action to take. |
@idivait late reply, but: no issues at that colo or with that metal (11f81) during that window. Note that @GeekyDeaks summary of the WebSocket RFC's details on server-client interactions is correct. I should also mention that WS clients will see a 1001 "Going away" from Cloudflare when we restart our machines during a rolling deploy of new releases. The Discord.js client appears to handle those correctly. Within limits, posting the details of /cdn-cgi/trace can be useful, but thus far the disconnects experienced in this thread seem to be unrelated to any broader network events. |
Hi, I think this issue might be resolved with the WebSocket rewrite I am doing; in the master branch, it's possible that the client may not resume properly and silently disconnect or remain online but not react to any events. You can try out the rewrite branch by installing discord.js from the If you experience any WebSocket-related issues after trying this out, please make a comment here |
I've recently experienced the described "remains online but does not react to any events" on the master branch, so i'll be sure to try the branch out and have a watch on the console. |
Discord.js's support for uWs has been improved in edf1a3e - it should behave nicely now! In case any of you were using uWs and experience this issue, try out the master branch and see if that fixes your problem. For normal ws users, the master branch has a few more fixes since I last commented; could you see if these fix your problems? Thanks! |
I think you can close this. I haven't personally had any issues since the WS rewrite. I also stopped using UWS but I was having disconnecting issues without it. Thanks for all your hard work 😄 |
Same here. I haven't experienced any of em lately. |
I haven't had any issues since the rewrite either. Thanks for the help guys. |
My issue seems related to issue #225.
The bot will run and show as logged in for a channel for some time and then it will suddenly drop offline. However, it will still post messages that are scheduled to a text channel.
autoReconnect is set to true as well.
For a look at my bot see: https://github.com/ericnelson0/GoHBot/blob/master/index.js
The text was updated successfully, but these errors were encountered: