普通网友 2019-03-07 17:06 采纳率: 50%
浏览 606

win10下的nginx+php做的socket访问一直超时

在win10 安装了php+nginx+mysql,phpinfo打印是正常的,但是在写了一个简单的socket的demo后,nginx一直报超时。
图片说明
就是这个错误。
nginx的错误日志:
2019/03/07 00:46:18 [error] 18316#16624: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /socket/client.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"

php的代码:
php代码是没有问题的,因为在apache下运行没问题。就是不知道nginx是什么情况。

$fp = fsockopen('localhost',80,$errno,$errstr,10); // 10秒超时
if (!$fp) {
    echo 'Error Code:'.$errno. '--Error Info:'.$errstr;
    die;
}
$http= '';
$http .= "GET /socket/server.php HTTP/1.1\r\n";

$http .= "Host: localhost\r\n";
$http .= "Connection: close\r\n\r\n";

fwrite($fp, $http);
$res = '';
while(!feof($fp)) {
    $res .= fgets($fp);
}
echo $res;
  • 写回答

1条回答 默认 最新

  • 序冢--磊 2019-03-08 15:17
    关注

    发送这个字符串 试试 "GET 127.0.0.1/socket/server.php HTTP/1.0\r\n\r\n"

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog