cURL错误28:10000毫秒后操作超时

时间:2020-02-28 13:00:37

标签: laravel guzzle

我对Guzzle HTTP客户端有疑问, 当我手动(使用邮递员)向post发送oauth/token请求时,我正确地获得了令牌并刷新了令牌,但是当我使用食尸鬼发送请求时,它冻结了,一段时间后没有任何响应超时返回异常底部

    "message": "cURL error 28: Operation timed out after 10000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)",
    "exception": "GuzzleHttp\\Exception\\ConnectException",
    "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php",
    "line": 200,
    "trace": [
        {
            "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php",
            "line": 155,
            "function": "createRejection",
            "class": "GuzzleHttp\\Handler\\CurlFactory",
            "type": "::"
        },
        {
            "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php",
            "line": 105,
            "function": "finishError",
            "class": "GuzzleHttp\\Handler\\CurlFactory",
            "type": "::"
        },
        {
            "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlHandler.php",
            "line": 43,
            "function": "finish",
            "class": "GuzzleHttp\\Handler\\CurlFactory",
            "type": "::"
....

这是我的代码

        $client = new \GuzzleHttp\Client([
            'timeout' => 10
        ]); //GuzzleHttp\Client
        try {
            $result = $client->post(url('oauth/token'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => $this->_client_id,
                    'client_secret' => $this->_client_secret,
                    'username' => $user->username,
                    'password' => $req->password,
//                'scope' => $scopes
                ]
            ]);
        } catch (\Guzzle\Http\Exception\ConnectException $e) {
            $response = json_encode((string)$e->getResponse()->getBody());
        }

我该怎么办?

0 个答案:

没有答案
相关问题