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

api.Spectator.GetCurrentGameAsync throws an exception #647

Open
PatriQ94 opened this issue Jan 31, 2020 · 9 comments
Open

api.Spectator.GetCurrentGameAsync throws an exception #647

PatriQ94 opened this issue Jan 31, 2020 · 9 comments
Labels

Comments

@PatriQ94
Copy link

Why does await api.Spectator.GetCurrentGameAsync throw an exception if the player is not in a game? It should either return the correct CurrentGame with populated data or return null.

@PatriQ94
Copy link
Author

Okay so upon further testing of this function I can confidently say that it doesn't work properly when a summoner leaves a match.

Here's the code that I used https://pastebin.com/eCPQzsFB
How its supposted to work: It checks every 5 seconds if a player entered a match, prints outs a message, then keeps checking until the player left the match, then prints a message.

How it behaves: It prints out a message when user entered a match, but when player leaves a match, the GetCurrentGameAsync sometimes throws an exception, sometimes it returns data of an already ended match and it's doing so for a few minutes after the player already left the match.

@xXLAOKOONXx
Copy link
Contributor

Is this issue based on RiotApi or RiotSharp?

@PatriQ94
Copy link
Author

PatriQ94 commented Jan 31, 2020

Is this issue based on RiotApi or RiotSharp?

RiotApi is a class within RiotSharp, so not sure exactly what you're asking. There's the exact code so you can check it out.

@MingweiSamuel
Copy link
Contributor

It's a question of whether this is an issue with Riot Game's API (https://developer.riotgames.com/) or RiotSharp. The API returns a 404 when the summoner is not in the game, so RiotSharp throws an error for that (I believe). (It doesn't necessarily have to behave this way).

If you're getting data back after a match ended, that is going to be 100% on Riot's API end. RiotSharp just handles requests to the API and returns whatever the API gave back.

@PatriQ94
Copy link
Author

PatriQ94 commented Feb 1, 2020

It's a question of whether this is an issue with Riot Game's API (https://developer.riotgames.com/) or RiotSharp. The API returns a 404 when the summoner is not in the game, so RiotSharp throws an error for that (I believe). (It doesn't necessarily have to behave this way).

I see, yeah makes sense. It's unfortunate that it throws error with "404 - Data not found" tho instead of simply returning null.

If you're getting data back after a match ended, that is going to be 100% on Riot's API end. RiotSharp just handles requests to the API and returns whatever the API gave back.

I'll do some more testing and contact Riot then.

@JanOuborny
Copy link
Contributor

I'm fairly sure, that returning a 404 error is the intended behavior, when the summoner isn't in a game.

@xXLAOKOONXx
Copy link
Contributor

One could argue 404 is null in http

@MingweiSamuel
Copy link
Contributor

I would argue 204 is more like null than 404 is, but Riot's API doesn't give 204s unfortunately

@PatriQ94
Copy link
Author

PatriQ94 commented Feb 1, 2020

Okay so I've contacted Riot and asked about this issue - why is their endpoint /lol/spectator/v4/active-games/by-summoner/{encryptedSummonerId} API returning random data (sometimes old data, sometimes an 404 exception). Keep in mind that this endpoint is connected to the problem I'm having with function GetCurrentGameAsync. So it looks like their distributed systems don't update caches fast enough and when I'm calling GetCurrentGameAsync I hit different servers, therefore getting random answers. They have also suggested to not call it more than once per minute or so, so their caches get updated.

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

4 participants