Getting Gateway Ratelimited.
My shards are getting interrupted a lot, in last 12 hours I got 291 reconnecting logs and more than double in last 24 hours.
Why is that? Is it normal? Cause I got gateway rate limited yesterday because of this.
Although I have a GitHub issue stating that reconnections are not rate limited. https://github.com/discord/discord-api-docs/issues/1369
I am extremely confused as how this (rate-limited) could happen?
The bot was not rebooted for few days before we got rate-limited.
34 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.npm list discord.js
node -v
While i noticed Resume event falls under Send Events which is also a part of 120 send events per connection per 60 seconds.
https://discord.com/developers/docs/topics/gateway#rate-limiting
https://discord.com/developers/docs/topics/gateway-events
+1
How do I know if they are identity or resumes?
resume event doesn't give me any info
The machine got blocked again today. @qjuh
I got this when I try to curl the gateway endpoint and use
-i
flag to show headers
Does this mean its a cloudflare ratelimit and not discord?
Or this is just how Discord blocks our requests? Using Cloudflare?
Hmm, I was inspecting logs and I see a tons of Unknown Interaction and Already Defered Error.
Would that be a problem?
Unknown Interaction is 404 ig
So 401 errors will be Invalid Webhook Tokens right?
403 is for channel and role permission. So I gotta check the permissions before sending.
How do I check that cause, its really random sometimes. Is deferred
reliable?
Hmm okay I will check that now
Thanks for the help
@qjuh Hey why are my shards are being closed with 4200 code?What does code 4200 mean?
Okay, so it fine right no issues?
Ah Thanks :)
Why the bot has spicks of huge invalid webhook token?
This is a monthly graph 7k+ logs
It can't be the code, how could it produce spikes like these lol
hmm
how do I montior that?
cause that weird
No I mean, how can I montior the load
Like what is causing it
Cause the machine is very powerful and it has the Bot and Mongodb server running
that's all
I am not monitoring that. I didn't know how to do that tbh
using Grafana
I don't think it has other monitoring in place rn
hmm
okay
let me do that
Already deferred is 400 error, is that also a problem?
Cause I am checking for
Interaction#defered
but someone some interactions are still throwing that error. So I am assuming that that field is not very dependable or not accurate all the time?Green Arrow: I am checking the defered field
Red Arrow: Getting those errors
Bump
I last 24 hours I got
131
Interaction has already been acknowledged errors
@qjuh
Now I don't have 2 instances of bots and Yes I am using collector and most of the Unknown interaction errors are happening in that collector.
I don't think 2 collectors are as I have collector attached to the message itself and it checks for member id to make sure onlt that member replies to the message.Common causes of
DiscordAPIError[10062]: Unknown interaction
:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
* Note: you cannot defer modal or autocomplete value responsesWhat does
Wrong interaction object inside a collector.
mean?
How could that happening? Cause I get like 300 Unknown interaction every hour.
I do check them for 3 seconds time frame and I instantly defer or reply to them.
Checked my code no issues found. But still somehow I get these unknown interaction errors.
Most of the interactions success but some just get failed with this error.
I also noticed most of them that are failing are using a colletor.
There are 0 reports of the feature that is causing this error not working or working incorrectly. So I am not sureThis i mean
updateCaptchaMessage
function call.
Just above
ya
Everything is fine to this point
No errors or issues.
Its also not like I am trying to update or using the main interaction, I am using the i
variable that is button interaction in the collector.
It always a new message when they click verify button
I tried clicking verify twice and more and it throws no errors
If you are worried about virus or something, I could just send you a pastebin
Okay gimme a min
Sent
Yes, I just did that actually. Still have to push that update in the live version. I will send you as soon as I push and get those logged.
What I feel so far is it could be either the code is talking more than 3 seconds to reach the update function or Discord API just lagging. I have seen Discord API lagging before but still not sure.
But that for Unknown Interaction
Yes
No idea about the acknowledged errors
-
DiscordAPIError: Interaction has already been acknowledged
- [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
You have already replied to the interaction.
- Use <Interaction>.followUp()
to send a new message
- If you deferred reply it's better to use <Interaction>.editReply()
- Responding to slash commands / buttons / select menusYeah, I know how it works
Okay
Interaction has already been acknowledged
I didn't quite get that
99% of them
Hmmmmmm
The main problem is no one has reported any issues with the numpad, I am not able to reproduce the issue
I don't think I ever coded anything like this, casue that would be a dead giveaway of the reason
Hmm okay
Hmm okay
I did that as well
lets see
What the heck?
Who could it say unknown interaction in just few milliseconds?
Interaction Created At - Errored At = 170ms
All of the 100s of errors are the same kind
Also, about the Interaction has already been acknowledged
error. Is there any way I can get the number of collectors on a message?
Here is that error
There are way many different event listeners on the whole bot...so Event Counts:
is really just unreliable.
Yeah, right thats for Interaction has already been acknowledged
What about the Unknown Interaction
tho?
How could this ever happen?
hmm okay let me build a cache system than
Hey, @qjuh So about this issue, I did debugging and found that somehow people where able to press readRulesContinue
button twice and it was adding 2 collectors to the same message. So I checked the code and it was defering
the button click and than using editReply
it was editing the message to the numpad captcha message. So I though its because I when I defer it the button gets active again for the user to be able to click and as I was using a event listener instead of using a one time collector like awaitMessageComponent
. So I though If I just use the update
function to instantly send the numpad captcha message. I could make it so the button will never have the time to get ready again (ready to be clicked). I did that and I was not able to reproduce this issue ever again. But somehow people are still able to click on the readRulesContinue
twice and I am getting 2 collectors on the same message.I could just check if a message already has a collector in place and it will ignore the second interaction but why this wouldn't work?
And I don't wanna add like hacks to the code tbh
max:1
for what tho?
I am not using awaitMessageComponent
You could check the code I sent in DMYes but I am not using that method because if the bot gets restarted anytime and a user is in middle of the verification flow, they will have to restart because that button won't work. I am listening to pure
interactionCreate
eventSo users can start on any step regardless if the bot got restarted or not
I know this is off topic, but please for the love of god make a proper button handler
I better managed the verification flow
Oh, any example like what do you mean?
like command handler - just with components
to avoid big chunky if else blocks
Yeah, I build a interactionEvent handler in the rewrite.
Its all divided now.
^
so thats an old pic or?
So it doesn't just manage buttons, It manages all the interactionCreate types.
Yes I rewrote the code.
ah gotcha,
This is the handler if you wanna check if I could improve anything @thehairy https://pastebin.com/PX6h8xRM
Pastebin
const { InteractionType } = require('discord.js');const Event = req...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Yeah, I mean the way rn I log that how many collectors a message has, I could just check the amount of collectors on a message and cancel the button click process right away but I am very curious that why do I have to implement a hack. How is discord allowing user to be able to click a button twice even tho I can sending an
update
reply?
The button should just keep processing and replace with new message. Isn't it?
Oh, so is that from our side or could be Discord as well?
No I meant the network traffic. Is it our network being slow or is it Discord talking time. I don't understand just a simple thing. The button should not be active (clickable by a user) for 3 seconds till my bot has replied.
It should I be active if I defer the update within 3 seconds time frame.
Ahh okay, and the second part any idea?
;__;
hmmmmmmmmmmmmmmmmmmmm
okay
I will add that check than
btw does this look good?
and also Thanks for all the time and help. Love ya :)
An example how Discord also lags sometimes
Interaction Created At
- Replied At
= 67ms
Replied At
- Errored At
= 15169ms
Btw need an advice, if I found an existing collector. Should I let the existing collector do the job or should I stop the old collectors and continue the code to send the update
with the numpad captcha message and make new collector? @qjuh
Oh, I am really sorry. I will remember.
Hmm
okay
Thanks