GatewayWorker无法启动

xlqt

我下载了GatewayWorker,本地win7正常启动,但一模一样的文件,上传到服务器后,启动报错,请求协助!

报错代码如下,8282端口就是开来给这个测试用的。
[root@ryzs ~]# php /www/ridd/GatewayWorker/start.php start -d
Workerman[/www/ridd/GatewayWorker/start.php] start in DAEMON mode
[root@ryzs ~]# stream_socket_server(): unable to connect to tcp://0.0.0.0:8282 (Address already in use) in file /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php on line 2233
PHP Fatal error: Uncaught exception 'Exception' with message 'Address already in use' in /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php:2235
Stack trace:

0 /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php(683): Workerman\Worker->listen()

1 /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php(541): Workerman\Worker::initWorkers()

2 /www/ridd/GatewayWorker/start.php(37): Workerman\Worker::runAll()

3 {main}

thrown in /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php on line 2235

Fatal error: Uncaught exception 'Exception' with message 'Address already in use' in /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php:2235
Stack trace:

0 /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php(683): Workerman\Worker->listen()

1 /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php(541): Workerman\Worker::initWorkers()

2 /www/ridd/GatewayWorker/start.php(37): Workerman\Worker::runAll()

3 {main}

thrown in /www/ridd/GatewayWorker/vendor/workerman/workerman/Worker.php on line 2235
^C
[root@ryzs ~]# php /www/ridd/GatewayWorker/start.php stop
Workerman[/www/ridd/GatewayWorker/start.php] stop
Workerman[/www/ridd/GatewayWorker/start.php] not run
[root@ryzs ~]#

4678 7 0
7个回答

xlqt

  • 暂无评论
抽不完的寂寞

8282端口被占用了

  • xlqt 2020-03-09

    可是我没有谁占用,我这个端口就是开来测试这个的,因为风站是https,唯一提到这个的地方就是服务器的配置里,可那就是为这个服务用的。

  • xlqt 2020-03-09

    listen 8282;
    server_name 域名;
    ssl on;

    ssl_certificate      证书地址;
    ssl_certificate_key  证书地址;
    ssl_session_timeout  5m;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
    
    location / {
    proxy_pass 访问端口;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    }
    
    # WebSocket 请求
    location /websocketChat {
    proxy_pass 访问端口;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }
    
    # WebSocket 请求
    location /websocketAudio {
    proxy_pass 访问端口;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }
  • xlqt 2020-03-09

    因为网站是开启了https的,如果不加这个,访问页面又会报错,说是试图访问一个不安全的地址被拦截。

xlqt
listen 8282;
    server_name  域名;
    ssl on;

    ssl_certificate      证书地址;
    ssl_certificate_key  证书地址;
    ssl_session_timeout  5m;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    location / {
    proxy_pass 访问端口;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    }

    # WebSocket 请求
    location /websocketChat {
    proxy_pass 访问端口;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }

    # WebSocket 请求
    location /websocketAudio {
    proxy_pass 访问端口;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }  
  • 暂无评论
xlqt

如果我在start_gateway.php里改端口,比如8283,服务是能启动了,但因为wss的问题,又会拦截。

  • 暂无评论
xlqt

开启之后,即便用cmd telnet也无法访问,回车后什么反应没有,再敲就出现下面的信息。
HTTP/1.1 200 Websocket
Server: workerman/3.5.29

<div style="text-align:center"><h1>Websocket</h1><hr>powered by <a href="https:/
/www.workerman.net">workerman 3.5.29</a></div>
C:\Users\Administrator>

  • 暂无评论
xlqt

现在是这样的,nginx配置里,得侦听8282端口,如果不加上,所有指向这个端口的请求则会被认为是不安全的请求被拒绝,如果加上了,start.php又无法启动,说端口被占用。怎样才能正常使用,请懂的人教我做一下,付酬劳也行.

  • 暂无评论
walkor 打赏

nginx 使用了8282端口,其它程序就不能使用8282端口了,gatewayWorker也不能,所以报错Address already in use

你这个应该是用nginx 的8282端口将请求转发给gatewayWorker,也就是nginx根据 8282端口根据请求的路径将请求分发到不同的实际端口。并不是让GatewayWorker也监听8282。

listen 8282;
    server_name  域名;
    ssl on;

    ssl_certificate      证书地址;
    ssl_certificate_key  证书地址;
    ssl_session_timeout  5m;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    # WebSocket 请求
    location /websocketChat {
    proxy_pass http://某ip:8283;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }

比如这个配置是说当nginx发现8282端口的请求的路径是/websocketChat时(例如wss://example.com:8282/websocketChat) ,nginx会把这个请求转发给后端的某ip8283端口。
比如你要用/websocketChat这个路径来访问你的gatewayWorker,那你就让gatewayWorker在某ip对应的服务器上监听8283并启动。

启动完毕后客户端连接8282端口时必须带上/websocketChat才能访问你的gatewayWorker。例如

// 正确用法
var ws = new WebSocket('wss://example.com:8282/websocketChat');
// 错误用法
var ws = new WebSocket('wss://example.com:8282');

另外telnet无法访问websocket协议,客户端和服务端要想能通讯,协议必须一致或者兼容,telnet协议和websocket协议明显是不同的协议。就像你用telnet访问mysql 3306端口一样,也是无法通讯。

  • 暂无评论
年代过于久远,无法发表回答
×
🔝