我对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());
}
我该怎么办?