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

better allow concurrent API streams #12346

Closed
ornicar opened this issue Feb 9, 2023 · 6 comments
Closed

better allow concurrent API streams #12346

ornicar opened this issue Feb 9, 2023 · 6 comments
Labels

Comments

@ornicar
Copy link
Collaborator

ornicar commented Feb 9, 2023

User feedback:


I wanted to use 2 streams
/api/stream/games-by-users to monitor all the games between our club members
/api/stream/games/{streamId} to monitor additional games our members are playing with other people so we can show whether they are available or not

The trouble is that having the 2 streams open, blocks me from making API calls that are needed in parallel. I get the error that I should not be making more than 2 request at the same time.

When I am connected to the 2 streams, any API calls I make (even single ones) return a 429 error. The ones we mainly use are these:
/api/users/status
/api/user/{username}/current-game
/game/export/{game}
/api/games/user/{username}
/api/challenge

@ornicar ornicar added the bug label Feb 9, 2023
@ornicar
Copy link
Collaborator Author

ornicar commented Feb 10, 2023

I can't reproduce it with the first endpoint mentioned, /api/users/status:

Here I'm streaming /api/stream/games-by-users and /api/stream/games/ simultaneously, yet I can still use /api/users/status without being limited.

@andreasantoniades
Copy link

Screenshot 2023-02-11 at 11 38 04

@andreasantoniades
Copy link

date; curl -X POST -d "andreant,katerinapap" "https://lichess.org/api/stream/games-by-users?withCurrentGames=true"
Sat Feb 11 11:37:11 GMT 2023
{"id":"EuDJPs71","rated":false,"variant":"standard","speed":"correspondence","perf":"correspondence","createdAt":1676115124584,"status":20,"statusName":"started","players":{"white":{"userId":"katerinapap","rating":1500,"provisional":true},"black":{"userId":"andreant","rating":1500,"provisional":true}}}


date; curl -X POST -d "EuDJPs71" "https://lichess.org/api/stream/games/andreant_test_stream"
Sat Feb 11 11:37:24 GMT 2023
{"id":"EuDJPs71","rated":false,"variant":"standard","speed":"correspondence","perf":"correspondence","createdAt":1676115124584,"status":20,"statusName":"started","players":{"white":{"userId":"katerinapap","rating":1500,"provisional":true},"black":{"userId":"andreant","rating":1500,"provisional":true}}}

date; curl -X GET "https://lichess.org/api/games/user/andreant?pgnInJson=true&opening=true&moves=true&finished=false&ongoing=true&max=1"
Sat Feb 11 11:37:40 GMT 2023
{"error":"Please only run 1 request(s) at a time"}[andreas@local] () [~]

@andreasantoniades
Copy link

andreasantoniades commented Feb 11, 2023

You are right, not all API calls fail (at least not consistently)
I will try more. So far:

  • /api/users/status WORKS
  • /api/games/user/{username} FAILS
  • /api/user/{username}/current-game WORKS
  • /game/export/{game} WORKS

@andreasantoniades
Copy link

So it seems to only be /api/games/user/{username} from the ones I checked. Apologies for the confusion, I listed the APIs we are using, not the ones that are actually failing.

@ornicar
Copy link
Collaborator Author

ornicar commented Feb 12, 2023

d5c7d82

this should fix it. It will be deployed in a day or 7.

@ornicar ornicar closed this as completed Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants