Client cannot login

After 6 months of running, I began having random issues yesterday with my bot not responding to interactions, and eventually not logging in, then other bots on the same machine not working. I've been going through lots of debugging and diagnosis, including downgrading to other versions, etc. I've only seen one rate limit error, the last time it successfully logged in. After that, no other bots on the machine can get through a client.login This is what the last successful connect looked like (see pitcure) where it ran for 6-7 hours, then had a long period of inactivity with log that looked like this:
[WS => Shard 0] Heartbeat acknowledged, latency of 20ms.
[WS => Shard 0] Heartbeat acknowledged, latency of 20ms.
19 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
DaveY
DaveYOP13mo ago
Last successful login:
DaveY
DaveYOP13mo ago
No description
DaveY
DaveYOP13mo ago
The next several hours of heartbeats had a couple of reconnects like this:
DaveY
DaveYOP13mo ago
No description
DaveY
DaveYOP13mo ago
Finally, no bot on the machine can login tonight. There were NO other errors prior to the next attempted bot interaction. It just hangs at the reconnect attempt
No description
DaveY
DaveYOP13mo ago
I suspect an IP ban. I've moved this bot to different server (dedicated) a couple times now over the last day
DaveY
DaveYOP13mo ago
But this is a game approaching 1000 hours of gameplay since April, almost 30k sessions which last 2 minutes or so each. I need a path forward for troubleshooting/support for possibilities, including reason for an IP ban. It's a pretty intense multiplayer combat game which reuses the same embed and generates a new attachment every few seconds. for up to 12 players or so at a time (per server). It's been very engaging for communities and hoping to go wider with it soon (in 50 servers now)
No description
DaveY
DaveYOP13mo ago
(It runs fine from local machine) Thanks 🙂 For posterity, running the bot on a new server/host tonight to see if it's a host issue!
d.js docs
d.js docs13mo ago
discord Rate Limits - Invalid Request Limit aka CloudFlare bans 429 responses are avoided by inspecting the rate limit headers documented above and by not making requests on exhausted buckets until after they have reset. 429 errors returned with X-RateLimit-Scope: shared are not counted against you read more
DaveY
DaveYOP13mo ago
I am not getting any 403 or 401 errors. I had a few per day from one server not having proper permissions, but I removed them Does discord.js provide a way to check rate limit buckets? I've looked through the docs and can't find reference except for the event handler for hitting the limit itself OK. I'm testing that tonight with only one server, one bot New host, dedicated server Thanks for the tips, this is fascinating and I look forward to knowing WTH I'm doing wrong 😉 Giving an update. After deploying on a new server and running some group tests, I definitely saw rate limits being hit. They tended to come in the Edit calls, as we are updating a main game embed every 3 seconds, along with player-specific ephemerals much more often. This corresponds to the PATCH endpoint, so I've made a request to see if we can have that bucket increased.
DaveY
DaveYOP13mo ago
No description
DaveY
DaveYOP13mo ago
No description
DaveY
DaveYOP13mo ago
I got a message back from Discord support about raising the rate limits.
Unfortunately, we can't raise the rate limit for any individual endpoint. We can only raise the global rate limit for a bot, and we can only offer that kind of support if a bot is in over 150,000 servers.

Note that, depending on the endpoint you're currently rate limited on, even a global rate limit increase may not solve the issue. We would instead recommend mitigating these issues by exploring sharding, exponential backoff, and other mitigation methods that may be available in your chosen library.
Unfortunately, we can't raise the rate limit for any individual endpoint. We can only raise the global rate limit for a bot, and we can only offer that kind of support if a bot is in over 150,000 servers.

Note that, depending on the endpoint you're currently rate limited on, even a global rate limit increase may not solve the issue. We would instead recommend mitigating these issues by exploring sharding, exponential backoff, and other mitigation methods that may be available in your chosen library.
I've determined that I'm hitting rate limits on the Patch endpoint (as seen in the screenshots above). I'm running this bot on a dedicated server, and am hitting this rate limit in only one guild when in heavy use, so it seems sharding isn't going to assist at this point. I don't have any real-time insight into what the rate limits or bucket size look like to understand how I can design around them. Is this something that can be surfaced PRIOR to hitting the rate limit? Yep! It's the "that often" part that I would love a little clarity on. I wouldn't think once every 3 seconds in a few guilds at a time is unreasonable, but I can't tell without knowing the bucket info
d.js docs
d.js docs13mo ago
Ratelimits are dynamically assigned by the API based on current load and may change at any point. - The scale from okay to API-spam is sliding and depends heavily on the action you are taking - Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
DaveY
DaveYOP13mo ago
Aha! I thought timeToReset was SECONDS imagine my pain lol OK, I think I can work with that I really thought I was only editing once per 3 seconds, will see if I'm doing something else that I forgot about (footer mods, etc) I am so sorry... I had removed all embed updates, but never removed the call to edit the message if there were NO updates 😦 So it was sending out an .edit once per second that was unneeded Mystery solved and I learned a LOT about rate limits
crxpt
crxpt13mo ago
I hope you don't mind me replying to an old message, but I want to do just this, but how would I go about using the proxy container to combine it with suck Is it fine if asked in here or shall i make my own post I hasn't realized this was a post I thought this was a message in channel And I wonder if I should get a host with a dedicated ip; I'm trying to run multiple bot sessions from same server I cannot fidn it anywhere on GitHub or any web search it just shows @discordjs/proxy sorryyyy 🙏 Ohh ok I didn't see oops Ah What are my options when it comes to needing to host multiple from the same server without like yk hitting rate limits or at least being able to manage the rates Some sort of challenge making the bots work together like interact with each other and that my goal but it needs multiple to run same server I would monitor multiple servers and they willl communicate data with each other or I'll just add to data base and get from database when needed but my uses would need multiple Like I run multiple bots for people on the same server to do their uses Like send message in like a notifier channel for their server every often or clear channels chats But sometimes it rate limit that why me ned help It's like custom for them is why Rn it's rlly static Like manual Wat which tos violate I not able run many custom bots at once? Oh It's fine cuz I work in a team with them I'm their developers
crxpt
crxpt13mo ago
The discord applications teams on the https://discord.com/developers/applications
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
crxpt
crxpt13mo ago
It allows see and reset token so Dang I see so many dif options tho idek what i need Like there's some that can have multiple bots, there's options like dedicated server to manage the rate limits and all that That's on that sparked hosting
Want results from more Discord servers?
Add your server