【问题标题】:The cURL request was retried 3 times and did not succeedcURL 请求重试 3 次,均未成功
【发布时间】:2020-01-26 12:05:56
【问题描述】:

我目前正在开发一个使用(Guzzle 客户端/Laravel)对自定义 API 的 REST API 调用。我已经通过添加错误的主体尝试了几次。我收到以下错误

cURL 错误 0:cURL 请求重试 3 次,均未成功。失败的最可能原因是 cURL 无法回退请求的正文,随后的重试导致相同的错误。打开调试选项,看看出了什么问题。请参阅https://bugs.php.net/bug.php?id=47204 了解更多信息。 (见http://curl.haxx.se/libcurl/c/libcurl-errors.html

以下是我的开发环境的详细信息:

 Language : php,
 Framework : Laravel 5.4,
 Client : Guzzle,
 OS : Ubuntu 16.04

我想知道这背后的原因

请在这件事上帮助我,

谢谢

以下是我的代码

{
    $headers = [
                'Content-Type' => 'application/json',
                'Authorization' => 'Bearer '.$this->accessTocken,
                'Accept' => 'application/json',
            ];

            $Body = [
                'method' => 'AndroidApp',
                'msisdn' => '94777400725',
            ];

            $client = new Client();

            $response = $client->post( $this->url, ['headers'=> $headers, 
             'json'=> $Body]);
}

【问题讨论】:

  • 看来需要配置本地SSL。
  • 在此 api 调用对同一服务器之前,另一个 api 调用正在工作。令牌创建工作正常。第二个 api 调用给出上述错误
  • 你检查过 laravel.log 文件吗?
  • 检查您的网络服务器的错误日志,因为它通常包含更详细的推理。

标签: php laravel laravel-5 runtime-error guzzle


【解决方案1】:

$response->getBody()->rewind();

为我工作

【讨论】:

    猜你喜欢
    • 2018-03-01
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-22
    • 2020-04-12
    • 1970-01-01
    相关资源
    最近更新 更多