简体   繁体   English

通过php-cli运行websocket服务器停止php-fpm以响应nginx

[英]Running websocket server over php-cli stop php-fpm to responds to nginx

I have a nginx server that serve http contents over port 8080 with php-fpm listening on 9002. 我有一个Nginx服务器,通过端口8080通过php-fpm在9002上侦听http内容。

Beside this, i have a websocket server socket (also php) running on port 9090. 除此之外,我还有一个在9090端口上运行的websocket服务器套接字(也是php)。

But when i start my websocket server in command line 但是当我在命令行中启动Websocket服务器时

php webSocketServer.php

my webserver on port 8080 stop to respond and stuck with a 504 code. 我的8080端口上的Web服务器停止响应,并停留在504代码上。 (Time-out Gateway) (超时网关)

I m using php7.2 on mac os 我在Mac OS上使用php7.2

log event : 日志事件:

 127.0.0.1 - - [24/Mar/2018:17:52:58 +0100] "GET /api/users HTTP/1.1" 504 183 "-" "GuzzleHttp/6.2.1 curl/7.54.0 PHP/7.2.3" "-"

i have iso-environement running on debian and both are perfectly working together. 我在debian上运行了iso环境,并且两者都可以完美地协同工作。

i had run 我跑了

sudo php-fpm -t 
[25-Mar-2018 16:08:40.993971] DEBUG: pid 2513, fpm_log_open(), line 50: open access log (/usr/local/Cellar/php/7.2.3_2/log/www.access.log)
[25-Mar-2018 16:08:40.994024] NOTICE: pid 2513, fpm_conf_init_main(), line 1743: configuration file /usr/local/etc/php/7.2/php-fpm.conf test is successful

and

sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

they both return successful configuration. 它们都返回成功的配置。

output from error.log with verbosity at debug: error.log在调试时的详细输出:

2018/03/26 20:14:20 [debug] 2887#0: timer delta: 1
2018/03/26 20:14:20 [debug] 2887#0: worker cycle
2018/03/26 20:14:20 [debug] 2887#0: kevent timer: 60000, changes: 0
2018/03/26 20:14:20 [debug] 2887#0: kevent events: 1
2018/03/26 20:14:20 [debug] 2887#0: kevent: 5: ft:-2 fl:0025 ff:00000000 d:146988 ud:00007FBF3000E8D1
2018/03/26 20:14:20 [debug] 2887#0: *60 http upstream request: "/index.php?"
2018/03/26 20:14:20 [debug] 2887#0: *60 http upstream dummy handler
2018/03/26 20:14:20 [debug] 2887#0: timer delta: 1
2018/03/26 20:14:20 [debug] 2887#0: worker cycle
2018/03/26 20:14:20 [debug] 2887#0: kevent timer: 59999, changes: 0

how i can reproduce this behavior: 我如何重现此行为:

  • nginx and php-fpm are started nginx和php-fpm启动
  • my web socket server is started in command line (php run.php) 我的Web套接字服务器在命令行中启动(php run.php)
  • i run tests to check connectivity to my web app via http request, no responses (until the next two steps) 我运行测试以检查通过http请求到我的Web应用的连接,没有响应(直到接下来的两个步骤)
  • i run tests to check connectivity to my websocket server , working. 我运行测试来检查与我的Websocket服务器的连接,是否正常工作。
  • i stop my websocket server (before timeout 65 from the http request) 我停止了我的websocket服务器(在HTTP请求超时65之前)
  • php-fpm respond to nginx... and all is working fine php-fpm响应nginx ...并且一切正常

what can i deduct ? 我可以扣除什么?

  • my web socket server running over php-cli stop php-fpm to send his response to nginx... 我的网络套接字服务器运行在php-cli上,停止php-fpm以将其响应发送给nginx ...

How i collected my data : 我如何收集数据:

  • ngrep -d any port 9002 ngrep -d任何端口9002
  • checkings logs and tests results 检查日志并测试结果

But i have no idea where the problems come from. 但是我不知道问题出在哪里。

There is no reason in the information you have provided to explain why starting a server on port 9090 would have any impact on another server listening on port 9001. Your description of the problem is also innacurate and misleading. 您提供的信息中没有任何理由可以解释为什么在端口9090上启动服务器会对监听端口9001的另一台服务器产生任何影响。您对问题的描述也是无意义的且具有误导性。 The webserver appears to be unaffected and is still responding. 网络服务器似乎未受影响,仍在响应。 It's php-fpm which is no longer responding. 它是php-fpm,不再响应。

Assuming that you've not built some hidden dependency into the system you've not told us about, then you should start by looking in your logs , and the output of netstat. 假设您尚未在尚未告知我们的系统中建立一些隐藏的依赖关系,那么您应该从查看日志和netstat的输出开始。 Would it have been so hard to test what happened with content served directly from nginx rather than php generated content after starting the websockets server? 启动websockets服务器后,很难测试直接从nginx提供的内容而不是由php生成的内容发生了什么?

It was a misunderstanding of my nginx configuration. 这是对我的nginx配置的误解。

I have centralized all my configurations on the nginx.conf file into the http scope instead of separate file for each configuration in scope server. 我已将nginx.conf文件中的所有配置集中到http作用域中,而不是将作用域服务器中每个配置的单独文件集中化。

The structure was as follows: 结构如下:

tcp
    http
     -- all configurations for server and websocket requests

All my http requests were handled in the scope "http". 我所有的http请求都在“ http”范围内处理。 When my websocket server was launch, classic http requests was not handled until the websocket request was ended. 当我的websocket服务器启动时,经典的http请求直到websocket请求结束才被处理。

The new structre is the now following: 现在,新的结构如下:

tcp
   http
       server php #separate file

       websocket php #separate file

       server spring #separate file

       server express #separate file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM