kevinohashi / php-riot-api

PHP Wrapper for Riot Games API
MIT License
75 stars 40 forks source link

Error 429 Rate limit exceeded #28

Closed pitchan closed 9 years ago

pitchan commented 9 years ago

Hello again,

I was thinking that the rate limiting was controled by the API with :

LONG_LIMIT_INTERVAL / SHORT_LIMIT_INTERVAL RATE_LIMIT_LONG / RATE_LIMIT_SHORT

If i exceed the rate limit, the API is not supposed to sleep and request again data when it's possible ?

Thanks in advance !

Best regards, CUETO Vincent

kevinohashi commented 9 years ago

That is correct. Can you show me how you're writing your code so I can take a look and try to figure out what's going on?

pitchan commented 9 years ago

Sure :) For exemple i tried this code in 3 steps : In the step 3.2 : Save games details i always get the error, impossible to have all gameDetails (I always get an array with : 429 error rate limit exceeded) This only works when a player have a single team with less than 5 games played.

    // New api insance
    $api = new RTPRiotApi($region); 
    // Step 1 : Get the summoner ID
    $summonerId = $api->getSummonerId($summoner);       
    // Step 2 : Get the teams of this player    
    $teams = $api->getTeam($summonerId);

    // Step 3 : For each team get data      
    foreach($teams[$summonerId] as $myTeam){    
        // filter RANKED_TEAM_5x5
        foreach($myTeam['teamStatDetails'] as $teamStatDetail){
            if($teamStatDetail['teamStatType'] == "RANKED_TEAM_5x5"){
                $teamWins = $teamStatDetail['wins'];
                $teamLosses = $teamStatDetail['losses'];
            }
        }
        // Step 3.1 : Save general stats
        $teamSave = new RTPSaveStats();     
        $teamSave->setTeamName($myTeam['name']);                
        $teamSave->setTeamId($myTeam['fullId']);
        $teamSave->setTeamTag($myTeam['tag']);
        $teamSave->setTeamWins($teamWins);
        $teamSave->setTeamLosses($teamLosses);
        $teamSave->setTeamRoster($myTeam['roster']['memberList'], $api);
        $teamSave->setLast20Games($myTeam['matchHistory']);

        // Step 3.2 : Save games details            
        foreach($teamSave->getGames() as $gameId => $game){                 
            $gameDetails = $api->getMatch($gameId);
            $teamSave->setGameDetails($gameDetails, $gameId, $game['win']);
        }
    }
kevinohashi commented 9 years ago

Ok that definitely sounds like the rate limiting queue isn't working.

Could you throw a couple debug statements in the updateLimitQueue() function to see when/where it's doing things? That seems to be the issue. I'd like to make sure it's getting called. Does it ever sleep? Is something wrong with the way it's queueing?

pitchan commented 9 years ago

I will try to find the moment when the code is on error state as soon as possible Thanks for helping !

Edit : I have some news about my issue

I created a function getRequestCount() in the api and the result is that it blocks after 11 requests for my account and two others then i tested another one and i got 40 requests done ...with no 429 error

Another thing is that i cleared the cache files and try again with my account when the bug appeared, and that worked

pitchan commented 9 years ago

I don't know why this bug appear .. For the moment i created a clear cache function and that's working ..

kevinohashi commented 9 years ago

Weird. I'm going to close this unless you figure out or have more details.