[英]php websocket connection establishment error
I have installed Symfony 3 on Ubuntu LAMP stack (PHP 7). 我已经在Ubuntu LAMP堆栈(PHP 7)上安装了Symfony 3。 I need websockets on my website so I:
我的网站上需要websockets,所以我:
Added gos/web-socket-bundle
to my symfony via composer 通过作曲家将
gos/web-socket-bundle
到我的symfony中
Set config: 设置配置:
gos_web_socket: server: port: 4000 host: mydomain.com
Opened port via firewall sudo ufw allow 4000/tcp
and sudo ufw allow 4000
. 通过防火墙打开的端口
sudo ufw allow 4000/tcp
和sudo ufw allow 4000
。
Then I started server php bin/console gos:websocket:server
and it's running. 然后,我启动了服务器
php bin/console gos:websocket:server
,它正在运行。
But when I try to connect from js: 但是当我尝试从js连接时:
var ws = new WebSocket('ws://mydomain.com:4000');
It gives the error: 它给出了错误:
WebSocket connection to 'ws://mydomain.com:4000/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
The comment provided by @drew010 resolved this for me. @ drew010提供的评论为我解决了这个问题。
In config.yml
set gos_web_socket.server.host
to 0.0.0.0
. 在
config.yml
设置gos_web_socket.server.host
到0.0.0.0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.