4

I am working on a project that is hosted on Google App Engine, and using app_devserver for local development. At the start I had problems with certificates but when I finally got over that error I am getting this new error

I am using Windows 10 and PHPstorm for development.

Error:

Message: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Looks like this error is saying that the request is made and successfull but the body could not be resolved or parsed? How can I resolve it?

This is my PHP code if needed: (simple call to tag manager api v2)

    $client = new Google_Client();
    $client->setAuthConfig('service_account.json');

    $client->setApplicationName("gtmdocx");
    /*$client->setScopes(['https://www.googleapis.com/auth/tagmanager.readonly',
                        'https://www.googleapis.com/auth/tagmanager.manage.accounts',
                        'https://www.googleapis.com/auth/tagmanager.edit.containers']);*/
    $client->setScopes(['https://www.googleapis.com/auth/tagmanager.readonly']);
    $service = new Google_Service_TagManager($client);
    $results = $service->accounts->listAccounts();


    echo $_GET['callback'] . '('.json_encode($results).')';
mustaccio
  • 18,234
  • 16
  • 48
  • 57
Asim
  • 936
  • 2
  • 10
  • 29

1 Answers1

4

I had exactly this problem using the Google Drive app, after hours trying to find a solution, I got it to work using the GuzzleHttp sink option

$client = new \Google_Client();
// ... Client Configuration

$httpClient = new Client([
    'sink' => 'path_to_any_temp_file',
    'base_uri' => $client->getConfig('base_path'),
]);
$client->setHttpClient($httpClient);

Worth the try.

Ramon Vicente
  • 761
  • 8
  • 12
  • 1
    Very nice! After hours of searching and debugging, I found the root cause and I️ ended up modifying Guzzles source directly to use a temp.txt file. This is obviously much better. – TheValyreanGroup Nov 11 '17 at 00:02
  • 1
    dude.... you have saved me from alot of frustration. thank you so much man. sending 3 years of hugs and thanks your way. – rip747 Aug 20 '20 at 09:54