douding_1073 2017-04-06 04:31
浏览 134
已采纳

操作在35007毫秒后超时,收到0字节

I installed nginx1.10 and php5.6 on windows 7,but I found that when I access the page it was unable to make curl request to the same script which use the same listen port.

There was an curl request in http://localhost/a.php,it to make a curl request to http://localhost/phpinfo.php, but an error got Error:Operation timed out after 35007 milliseconds with 0 bytes received.

server {
    listen 80;
    server_name localhost;
    root d:/localhost;
    index index.html index.htm index.php;
    autoindex on;
    autoindex_localtime on;

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}




http://localhost/a.php


<?php
function makeRequest($url, $params, $method = 'GET')
{
    $ch = curl_init();
    if ($method == 'GET') {
        $url .= '?' . http_build_query($params);
    } else {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    }

    if (substr($url, 0, 6) == 'https:') {
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_USERAGENT, 'ApiClient/v1.0');
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 35);


    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    $error = curl_error($ch);

    curl_close($ch);
    print_r($info);
    var_dump($error);
    return $result;
}


$url = 'http://localhost/phpinfo.php';
makeRequest($url, []);

output:

Array
(
    [url] => http://localhost/phpinfo.php?
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 96
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 35.007
    [namelookup_time] => 0.016
    [connect_time] => 0.219
    [pretransfer_time] => 0.219
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 127.0.0.1
    [certinfo] => Array
        (
        )

    [primary_port] => 80
    [local_ip] => 127.0.0.1
    [local_port] => 55978
)

D:\localhost\a.php:37:string 'Operation timed out after 35007 milliseconds with 0 bytes received' (length=66)

I have found that if you use a different port, the PHP that initiates the request uses the A port, and the response to the request's PHP uses another port, and the execution timeout does not occur.

  • 写回答

1条回答 默认 最新

  • dsf11t5u1651 2017-04-23 15:04
    关注

    I know why,Because php-cgi is not php-fpm, php-cgi will not automatically start the new process, so once occupied will be locked.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果