jagrosh / MusicBot

🎶 A Discord music bot that's easy to set up and run yourself!
https://jmusicbot.com
Apache License 2.0
5.42k stars 2.58k forks source link

[Bug Report] [WARN] [RateLimiter]: Encountered 429 on route #1254

Open dandroid126 opened 2 years ago

dandroid126 commented 2 years ago

Bug Description

Getting errors every second in the journalctl with the below warning, and commands issued through discord are significantly delayed. The amount of delay appears to get worse as time goes on. After restarting the service, the bot responds to commands like normal. After about 2 hours, command responses are delayed by about 80 seconds. After 12+ hours, command responses are delayed by 2+ hours. I am only playing a single default playlist which contains 111 local songs. I'm not sure the exact repro steps, but this is the setup I currently have.

EDIT: Found out that this does not happen unless I use the nowplaying command. Updating the repro steps reflect this.

Nov 28 19:35:34 dan-server java[100921]: [19:35:34] [WARN] [RateLimiter]: Encountered 429 on route PATCH/channels/{channel_id}/messages/{message_id} with bucket 1d3c67957bcdccc6709861c232df8529:channel_id=888868452260003842 Retry-After: 1000 ms

Environment:

PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Service file:

[Unit]
Description=DJ Ai
After=multi-user.target

[Service]
WorkingDirectory=/mnt/ApertureLabs/DJ_Ai
User=root
ExecStart=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Dnogui=true -jar JMusicBot-0.3.8.jar
Restart=always

[Install]
WantedBy=multi-user.target

Using Java 8 and Java 17 yields the same results

Settings:

{"391427484702212103": {
    "voice_channel_id": "391427485168041986",
    "text_channel_id": "888868452260003842",
    "default_playlist": "utapri"
}}

image

Steps to Reproduce

  1. Create a playlist with many local songs (100+)
  2. Run the program as a service on Ubuntu 22.04.1 LTS
  3. Set the playlist as the default playlist
  4. Run the nowplaying command*
  5. Let the bot play music for 2+ hours
  6. Run the ping command and see how long it takes to respond.

*Added step 4 with an edit

Expected Result

Bot should respond to commands quickly, even after many hours of continuous playback with nowplaying command*.

*edited to reflect nowplaying command

Debug Output

System Properties: java.version = 1.8.0_352 java.vm.name = OpenJDK 64-Bit Server VM java.vm.specification.version = 1.8 java.runtime.name = OpenJDK Runtime Environment java.runtime.version = 1.8.0_352-8u352-ga-1~22.04-b08 java.specification.version = 1.8 os.arch = amd64 os.name = Linux

JMusicBot Information: Version = 0.3.8 Owner = 378038763319853063 Prefix = ! AltPrefix = null MaxSeconds = 0 NPImages = false SongInStatus = true StayInChannel = false UseEval = false UpdateAlerts = true

Dependency Information: JDA Version = 4.4.0_352 JDA-Utilities Version = 3.0.5 Lavaplayer Version = 1.3.78

Runtime Information: Total Memory = 284 Used Memory = 72

Discord Information: ID = 1033943863204786186 Guilds = 1 Users = 2

Additional Info

No response

Checklist

shello commented 2 years ago

We were having this issue with our deployment of JMusicBot a few minutes ago. Member's commands were taking multiple seconds to get a response, and the RateLimiter messages kept piling up in the log.

It seems that the culprit this time was a reply to a !nowplaying command from earlier in the same session that was still being updated by the bot; once I manually deleted that message from the channel, the RateLimiter messages ceased to appear in the log, and commands such as !ping got a response instantly.

r4nx commented 1 year ago

Seems like merging the fix may take some time, so you might want to use a custom build from my branch. Build process isn't described anywhere, but is simple, the prerequisites are installed JDK and Maven.

  1. git clone https://github.com/r4nx/MusicBot.git
  2. cd MusicBot
  3. git switch update-np
  4. mvn clean package

The .jar file you need is located at target/JMusicBot-Snapshot-All.jar. Then you'll be able to either increase the interval of updating with updatenptime option, or disable it completely with updatenp = false. See default config for reference.

Hope that helps.

newmania commented 1 year ago

If you set npimages = true in config.txt, it won't update Now Playing embeds anymore.