Wednesday, 9 December 2015

RateExceededError rate limiter is broken


It says to wait 30s. I waited 31s. It still complains. It's single-threaded. 


2015-12-09 18:11:42.944083+00:00 heroku scheduler.5645 - - Starting process with command `php yii kw/stats` Context
2015-12-09 18:11:48.820233+00:00 app scheduler.5645 - - Warning: [RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30>] Context
2015-12-09 18:11:48.820719+00:00 app scheduler.5645 - - Sleeping 30 seconds. Context
2015-12-09 18:11:43.582785+00:00 heroku scheduler.5645 - - State changed from starting to up Context
2015-12-09 18:12:19.973304+00:00 app scheduler.5645 - - Error: Giving up. [RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30>] Exception Context
2015-12-09 18:12:20.841574+00:00 heroku scheduler.5645 - - Process exited with status 0 Context
2015-12-09 18:12:20.857147+00:00 heroku scheduler.5645 - - State changed from up to complete Context

Code

      // Make the get request.
      try {
        $retry = false;
        $page = $targetingIdeaService->get($selector);
      } catch (\SoapFault $e) { 
        Yii::error($e->getMessage());
        echo ("Warning: ".$e->getMessage().PHP_EOL);
        $errors = \ErrorUtils::GetApiErrors($e);
        foreach ($errors as $err) {
          if ($err->ApiErrorType == 'RateExceededError' && $err->retryAfterSeconds < 60) {
            echo "Sleeping $err->retryAfterSeconds seconds.\n";
            sleep($err->retryAfterSeconds+1);
            $retry = true;
          }
        }         
        if ($retry) {
          try {
            $page = $targetingIdeaService->get($selector);
          } catch (\SoapFault $e) {
            Yii::error($e->getMessage());
            echo "Error: Giving up. ".$e->getMessage().PHP_EOL;
            exit;
          }
        }
        else {
          echo "Error: Giving up.\n";
          exit;
        }

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/ef330481-fb2a-40af-94c8-eccf7435b06a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment