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 not sending all messages, updating status, or updating channel topic #139

Open
AllOutJay opened this issue Dec 28, 2024 · 28 comments
Open

Comments

@AllOutJay
Copy link

Information

Minecraft version: 1.21.4
Modloader: Fabric
Fabric loader version: 0.16.9
Environment: Multiplayer

Description

Some days, the bot does not send all messages that people on the server send, it could also be events like people joining, leaving, dying, etc; The bot doesn't always update its status on Discord, and it doesn't always update the channel topic. Not really sure why it does, but a temporary solution sometimes is restarting the server.

Config file: https://mclo.gs/kpMNHd5

@Kaleidio
Copy link
Collaborator

Kaleidio commented Dec 28, 2024

Bots are not allowed to change their statuses very often due to discord's api rate limit rules. If i recall correctly we have it hard coded to twice every thirty minutes. Channel topics are especially like this, as discord's rules only allow 5 changes per day as far as I know.

Similarly here, you're getting ratelimited by messages and player events. This would cause the bot to stop responding to discord a couple minutes at a time. Usually, there's nothing we can do about that, as that's just how discord's api rules work. You need to ask your players not to spam messages, if possible.

Read the logs of your server, or send them here next time the ratelimiting happens, so we can help tell you when exactly that has occured.

@hypherionmc
Copy link
Owner

The behavior does sound like ratelimits for sure, but then the next question is why.

You would need to have some serious spamming going on, to use up all 50 requests per second. My guess would be a command or commands being spammed to your discord.

The other reason could be, if you are sharing bot tokens across bots, or in some really rare cases, if your hosting provider has a lot of discord bots running on their server, sharing the same IP, you could all get global ratelimited by discord.

Webhooks have much worse ratelimits, of 15 (I think) per minute, but the webhooks being ratelimited, shouldn't stop the other things on the bot from working

@AllOutJay
Copy link
Author

My server has no one spamming or spamming commands. I also don't have the bot logging that either. I have at most, 5 people playing and sending like 10 messages within 5 minutes.

I don't really know much about Discord bots, but my Discord bot token is only used for this Discord Minecraft Chat Bot. My server host provides dedicated IPs as well, so I am the only Discord bot for my IP.

The bot can entirely stop working for the day randomly it seems even despite a server restart. For example today/currently:

There you can see events like logging in and out are missing and the bot's status is also missing.

@hypherionmc
Copy link
Owner

[05:12:19] [pool-2-thread-2/WARN]: Tried to relay discord message before bot is ready. Aborting

Something is preventing your bot from completing the startup process.

Try running your server with debugging enabled, and see if it happens again. The debugging will spam your logs quite a bit more, but it should help us track down any issues.

Additional, what host are you using for your server?

@AllOutJay
Copy link
Author

I'll enable debug mode and see how things go then.

I use Bloom for hosting. https://bloom.host/

@hypherionmc
Copy link
Owner

Awesome, thanks.

It's the first time we have a report from a bloom user, but not an uncommon issue. For some reason we can't replicate this issue to test potential fixes, or even figure out what the real cause is

@AllOutJay
Copy link
Author

Restarted the server with debug mode enabled. Join / Disconnect messages don't seem to work nor do the channel topic and bot status updates. Player messages from in-game work. Messages sent via Discord don't get sent to Minecraft.

@Kaleidio
Copy link
Collaborator

about five seconds before the server suddenly considers itself not ready:

[19:19:41] [Server thread/WARN]: Expected to get Channel for JOIN, but got null

@hypherionmc
Copy link
Owner

Yeah, so it's getting stuck in the cache loading stage. Interesting.

The reason the player messages works, is because it uses webhooks, so it doesn't care that the cache is null

@hypherionmc
Copy link
Owner

@AllOutJay how accurately can you recreate this issue? Does it occur on every startup, or only every x amount?

@AllOutJay
Copy link
Author

@hypherionmc I would say recently, it has been more frequent like an almost every day occurrence. Sometimes it naturally resolves itself and sometimes it goes back to not working.

I restarted it again, and it still isn't playing nice. I feel like this has only started to occur back in October and it only has increasingly gotten worse.

@hypherionmc
Copy link
Owner

October and it only has increasingly gotten worse.

Round about the time there has been a spike in reports about this.

I don't remember any massive code changes around that time that would cause this.

Reason I'm asking, is I have an idea of where it gets stuck, but not sure why. I would need to send you a debug jar that adds some additional logging at the suspected points, so we can see what discord is doing

@AllOutJay
Copy link
Author

Happy to do whatever I can to help diagnose! I thought it was strange that it eventually started to act, but I wasn't sure if something changed since October on the mod side or on the Discord side, which it seems like nothing should have changed.

@hypherionmc
Copy link
Owner

SimpleDiscordLink-Universal-3.2.2+release.2.jar.zip

Sorry for the zip. GitHub does not like jar files

@AllOutJay
Copy link
Author

It all appears to be working now. I did notice some funky stuff in the log, but I am not sure if that is just due to the debug jar.

  • ie "[21:02:09] [pool-2-thread-1/ERROR]: Failed to load account database: Cannot invoke "String.equals(Object)" because the return value of "com.hypherionmc.sdlink.core.database.SDLinkAccount.getDiscordID()" is null"
  • Logs: https://mclo.gs/O6ASlRH
  • Discord chat

@hypherionmc
Copy link
Owner

hypherionmc commented Dec 30, 2024

That error is normal on servers that don't use access control.

Keep an eye on it for when it happens again please.

I am mostly interested in this: [20:45:01] [pool-2-thread-1/ERROR]: Got OnReady with status CONNECTED. If it gets stuck again, I want to see what the output of this is

@AllOutJay
Copy link
Author

@hypherionmc It has been working fine the past few days, but it eventually broke today after a restart.

@hypherionmc
Copy link
Owner

hypherionmc commented Jan 2, 2025

Fantastic (not that it broke, but that we now actually know where it's getting stuck).

Basically, LOADING_SUBSYSTEMS is an internal stage the discord api library we use runs through during bot startup. For some reason, it's getting stuck on that and not going back to connected


EDIT: I think I found the source of the bug. It's a little late now, but I'll push out a snapshot build later today. That will hopefully fix this issue once and for all

@AllOutJay
Copy link
Author

@hypherionmc Glad to hear that this helped you identify the problem! I'll be on the lookout for the snapshot build.

@hypherionmc hypherionmc added Type: Bug Something isn't working Severity: Major labels Jan 3, 2025
@hypherionmc
Copy link
Owner

Thanks for your patience and help in identifying this as well. For some reason, it's never been possible for us to recreate this bug at all.

The main issue is, that the event we rely on to know that the bot is now ready to start working, is the wrong one. My working theory on why we can't recreate it, is because the hardware we use for testing (local and server), is powerful enough to execute the code in such a way, that it works as we expect it to work.

On shared hosting, the hardware itself is normally either overloaded, or under heavy load, making it possible for the bug to appear. Honestly, the bug should not have made it possible for the mod to work AT ALL

@hypherionmc
Copy link
Owner

Snapshot is out :) https://nightbloom.cc/project/sdlink/files/5KzOnxqE

@hypherionmc hypherionmc added Status: Fixed In Dev Issue has been fixed, but still needs to be released Status: Awaiting release Implemented/Fixed, but awaiting release labels Jan 3, 2025
@AllOutJay
Copy link
Author

Installed the snapshot! Will let you know if I face any problems.

@AllOutJay
Copy link
Author

AllOutJay commented Jan 10, 2025

After a successful week or so of using SimpleDiscordLink-Universal-3.2.2+release.2.jar, the issue came back :( Restarting the server did fix it afterwards

@hypherionmc
Copy link
Owner

Can you tell me more or less what happens when this bug is usually triggered? Like what's the state of your server, what happens before the bug occurs etc?

@AllOutJay
Copy link
Author

For today, it was working fine, but then I stopped the server to install updated mods. Upon booting it up after updating the mods, it was not working like before (status, channel topic, message from Discord to game). How I noticed is that a player got on 10 or so minutes after the restart, but no message was sent to the Discord channel.

@hypherionmc
Copy link
Owner

Odd.....

Then I am out of ideas on this one. I think what I'm going to do, is add a flag if the bot connects, but is on that LOADING_SUBSYSTEMS state, then recheck after 5 seconds to see if it has changed. If after 10 seconds it has not, just force the bot to continue and hope that nothing breaks.

I really can't imagine what else would cause this

@hypherionmc hypherionmc added Status: Investigating and removed Status: Fixed In Dev Issue has been fixed, but still needs to be released Status: Awaiting release Implemented/Fixed, but awaiting release labels Jan 11, 2025
@hypherionmc
Copy link
Owner

hypherionmc commented Jan 12, 2025

Implemented the checker. If the bot starts on that LOADING_SUBSYSTEMS state, it will check every 5 seconds to see if the bot has changed to ready. That way it can clear that loop, even if the event doesn't fire again

https://nightbloom.cc/project/sdlink/files/PhdRpAEH

Edit: Previous link had a bug with the new spam checker. https://nightbloom.cc/project/sdlink/files/QS83Mer0

@AllOutJay
Copy link
Author

Installed it today. Will let you know if I face any issues.

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

No branches or pull requests

3 participants