PHP cURL POST请求需要很长时间(超过20秒)才能完成

时间:2018-03-10 11:58:03

标签: php curl post

我正在使用本地运行的PHP代码向远程地址发出请求:

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

print_r(curl_getinfo($curl));

返回的信息如下:

Array
(
    [url] => xxxxxxxxxxxxxxxxxxxxxxx
    [content_type] => text/html; charset=UTF-8
    [http_code] => 200
    [header_size] => 397
    [request_size] => 316
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 22.844
    [namelookup_time] => 0
    [connect_time] => 0.016
    [pretransfer_time] => 0.016
    [size_upload] => 143
    [size_download] => 51819
    [speed_download] => 2268
    [speed_upload] => 6
    [download_content_length] => -1
    [upload_content_length] => 143
    [starttransfer_time] => 22.719
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => xxxxxxxxxx
    [certinfo] => Array
        (
        )

    [primary_port] => 80
    [local_ip] => xxxxxxxxxx
    [local_port] => 64907
)

请求也返回一个有效的响应,只是加载PHP页面需要20多秒,而curl_getinfo似乎表明它不应该花费这么长时间。

我已经尝试过各种各样的事情来尝试解决这个问题,但是它们似乎都不起作用,对不起,如果我在这里遗漏了一些明显的东西。

感谢。

0 个答案:

没有答案