使用请求10001毫秒后连接超时

时间:2018-07-20 12:31:50

标签: php curl httprequest

我可以使用波纹管来访问oauth令牌:

curl -X POST -d "grant_type=password&username=test30&password=123456" -u"AD2fFTuUmce1jsnMHmCEPGkY3jDROjAAoNPkDyuc:Ve3AOBHsl7oFopZyWHZAwilEOIsblU8CPmU6v0wXMBRUn6UyoF1eM4YlCD94RMtietW0siIlLKarrowJmKUltBHBFt1xGhuCjQrTmpZeX40l7187E9U3V4xDBKtNAPcI" http://103.200.31.xx:8000/o/token/

结果如下:

{"token_type": "Bearer", "expires_in": 36000, "refresh_token": "0ULYiq5QpS3V5FjgGTygeoZZ5gO0Yf", "scope": "read write groups", "access_token": "SgFdP7rPBdoYoUG9hmjS3HvlcILFF6"}

但是为什么我将请求用于令牌请求,会出现错误?

    $request = Requests::post('http://103.200.31.xx:8000/o/token', [
        // headers
    'Accept'=>'application/json'
 ], ['username'=>'test30', 'password'=>'123456'], [
        // options
        'auth' => new Requests_Auth_Basic(['AD2fFTuUmce1jsnMHmCEPGkY3jDROjAAoNPkDyuc', 'Ve3AOBHsl7oFopZyWHZAwilEOIsblU8CPmU6v0wXMBRUn6UyoF1eM4YlCD94RMtietW0siIlLKarrowJmKUltBHBFt1xGhuCjQrTmpZeX40l7187E9U3V4xDBKtNAPcI'])
    ]);

    return $request;

错误报告:

Fri Jul 20 11:56:11.450296 2018] [proxy_fcgi:error] [pid 5122:tid 139663067014912] [client 118.113.136.138:19584] AH01071: Got error 'PHP message: [WHMCS Application] ERROR: Requests_Exception: cURL error 28: Connection timed out after 10001 milliseconds in /usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests/Transport/cURL.php:422 Stack trace: #0 /usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('', Array) #1 /usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests.php(379): Requests_Transport_cURL->request('http://103.200....', Array, Array, Array) #2 /usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests.php(268): Requests::request('http://103.200....', Array, Array, 'POST', Array) #3 /usr/local/httpd/htdocs/whmcs/qi_cloud/utils/utils.php(35): Requests::post('http://103.200....', Array, Array, Array) #4 /usr/local/httpd/htdocs/whmcs/qicloud_dedicate_servers.php(88): fetch_qicloud_access_tokens(Array) #5 {main} {"exception":"[object] (Requests_Exception(code: 0): cURL error 28: Connection timed out after ...\n', referer: http://www.example.net/qservers.php

EDIT-01

我将超时设置为30,仍然是此错误after 10000 ms xxx

[
    // options
    'auth' => new Requests_Auth_Basic([QICLOUD_whmcs_pj_client_id, QICLOUD_whmcs_pj_client_secret]),
    'timeout' => 30,
]

错误在哪里?


EDIT-02

我也将connect_timeout设置为30,但仍然收到超时错误,说:

  

30002毫秒后连接超时

我不认为设置超时是解决方案,因为我使用curl,所以它非常快速地请求令牌。

0 个答案:

没有答案