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

Discord backend locks up - Suspect rate limits #189

Open
Kickbut101 opened this issue Nov 13, 2019 · 7 comments
Open

Discord backend locks up - Suspect rate limits #189

Kickbut101 opened this issue Nov 13, 2019 · 7 comments
Labels
bug pinned Prevent closing if stale

Comments

@Kickbut101
Copy link

Kickbut101 commented Nov 13, 2019

#142 - Seems to be duplicate of this ticket!

Expected Behavior

I should be able to add-remove-update plugins at will and have the backend respect discords rate-limits so as not to lock up or lose connection to API.

Current Behavior

Currently something as simple as !Update-Plugin locks up the api with the last errors showing (verbose)

05:51:22Z","Class":"DiscordBackend","Method":"_WaitRateLimit","Severity":"Warning","LogLevel":"Info","Message":"Rate
limit reached. Sleeping [0.250] milliseconds","Data":{}}
WARNING: {"DataTime":"2019-11-13
05:51:22Z","Class":"DiscordBackend","Method":"_WaitRateLimit","Severity":"Warning","LogLevel":"Info","Message":"Rate
limit reached. Sleeping [0.250] milliseconds","Data":{}}
WARNING: {"DataTime":"2019-11-13
05:51:22Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Warning","LogLevel":"Info","Message":"{\n
"global": false, \n "message": "You are being rate limited.", \n "retry_after": 138\n}\n","Data":{}}

Possible Solution

  • Add a delay to the reaction emojis, so that they don't try to fire off as quickly
  • Make sure the rate limiting function/code you already have in place exists on all communications with discord api (through the backend I assume?)
  • Allow emojis to be turned off from PoshBotConfig.psd1 file ?
  • Put in a counter to increase the ratelimit delay each successive time it sees it? Kind of like a cooldown

Steps to Reproduce (for bugs)

  1. Build 0.12.0 poshbot
  2. Connect bot and app in discord via https://poshbot.readthedocs.io/en/latest/guides/backends/setup-discord-backend/
  3. Follow this page to make test plugin https://poshbot.readthedocs.io/en/latest/tutorials/plugin-development/simple/
  4. Change the test plugin .psm1 file (I literally changed it from just write-output, to having an if statement to check if user input a username along with the !invoke-helloworld command).
  5. Try !update-plugin
  6. For me at this point it locks up, see the error log above.

Context

Just trying to build some bot in discord for personal use among myself and friends

Your Environment

  • Module version used: 0.12.0
  • Operating System and PowerShell version: Win10 1903, powershell 5.1 I believe?
@Adamvg
Copy link

Adamvg commented Nov 20, 2019

Allow emojis to be turned off from PoshBotConfig.psd1 file ?

They can be turned off from the starting script:
$pbc.AddCommandReactions = $false

@devblackops
Copy link
Member

@Kickbut101 Can you expand on what you mean by "lock up"? You will see rate limit messages in the log but there should be no loss of functionality.

The Rate limit reached messages are normal for reactions as Discord has a very low rate limit on them. We act on the rate limit headers received from Discord and sleep accordingly.

@Kickbut101
Copy link
Author

Kickbut101 commented Nov 22, 2019

@Kickbut101 Can you expand on what you mean by "lock up"? You will see rate limit messages in the log but there should be no loss of functionality.

The Rate limit reached messages are normal for reactions as Discord has a very low rate limit on them. We act on the rate limit headers received from Discord and sleep accordingly.

You bet!

My powershell ISE will lock up in "running" mode without allowing me to break the script which results in me having to "End Task" in task manager to get it to finally close/stop. In addition to this the bot becomes unresponsive and no longer listens or fulfills commands (like !status or !about or anything). I believe I also tried to run the script as a standalone script (running it just in a normal powershell console, outside the powershell ISE) and got same results.

This was a while ago so my memory on it is not quite as clear as it was. But I bet I can recreate it when I get home if you'd like.

@stale
Copy link

stale bot commented Jan 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 22, 2020
@devblackops devblackops added the pinned Prevent closing if stale label Jan 24, 2020
@stale stale bot removed the stale label Jan 24, 2020
@devblackops
Copy link
Member

Is this still an issue @Kickbut101?

@Kickbut101
Copy link
Author

I am unsure what causes it but the .12 build I made long ago does still die on it's own for some reason. It's probably not at all related to rate limits. But It will lock up and the powershell console will still be "running" but the bot status on discord goes to offline and no commands are accepted/run.

Again though, probably not rate limit related. More likely just a bad build on my part? Unsure. You can close this one.

@Adamvg
Copy link

Adamvg commented Mar 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pinned Prevent closing if stale
Projects
None yet
Development

No branches or pull requests

3 participants