URL error 0: The cURL request was retried 3 times and did not succeed

纵然是瞬间 提交于 2019-12-29 08:53:04

问题


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).')';

回答1:


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.



来源:https://stackoverflow.com/questions/46323867/url-error-0-the-curl-request-was-retried-3-times-and-did-not-succeed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!