lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
768 stars 449 forks source link

Endpoint /api/stream/event is rate limited. Waiting 0:01:00 seconds until next request. #943

Closed ezhang7423 closed 6 months ago

ezhang7423 commented 7 months ago

Describe the bug When running this repository from scratch with no modifications, I am getting this error:

<Response [429]> 429 {"error":"Please don't poll this endpoint, it is intended to be streamed. See https://lichess.org/api#tag/Board/operation/apiStreamEvent."}

Endpoint /api/stream/event is rate limited. Waiting 0:01:00 seconds until next request.

To Reproduce Steps to reproduce the behavior:

  1. Run lichess-bot after following instructions in README.md: python lichess-bot.py
  2. See error

Expected behavior I expect that getting events should be able to succeed.

Logs

old.log recent.log

image

Desktop (please complete the following information):

ezhang7423 commented 7 months ago

Digging further, it seems like the code will call /api/stream/event several times in rapid succession:

https://lichess.org/api/stream/event None 15 True
[04/12/24 08:42:14] INFO     Next challenge will be created after 08:43:14 (0 challenges in last 24 hours)         matchmaking.py:292
<Response [200]> 200 
https://lichess.org/api/stream/event None 15 True
<Response [200]> 200 
https://lichess.org/api/stream/event None 15 True
<Response [200]> 200 
https://lichess.org/api/stream/event None 15 True
<Response [200]> 200 
https://lichess.org/api/stream/event None 15 True
<Response [200]> 200 
https://lichess.org/api/stream/event None 15 True

This happened within the course of a second...

ezhang7423 commented 7 months ago

Another interesting note...this seems to happen because of a certain API token. When switching to a different API token, there is no issue...

MarkZH commented 7 months ago

What scopes are on the two API tokens? Go to the API access tokens page in your bot's preferences on lichess to see a list. Label the lists to indicate which one causes problems and which doesn't.

ezhang7423 commented 7 months ago

Both API tokens have the correct scopes - the API token that is currently not working was working just a few days ago. If you're open to it, I can DM you privately the API token to debug with.

MarkZH commented 7 months ago

@ezhang7423 Sure, that will be useful. I'm m.z.h on the lichess discord server.

MarkZH commented 6 months ago

Please reopen if the problem persists and you can provide more details.