简体   繁体   English

php websocket连接建立错误

[英]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,所以我:

  1. Added gos/web-socket-bundle to my symfony via composer 通过作曲家将gos/web-socket-bundle到我的symfony中

  2. Set config: 设置配置:

gos_web_socket: server: port: 4000 host: mydomain.com

  1. Opened port via firewall sudo ufw allow 4000/tcp and sudo ufw allow 4000 . 通过防火墙打开的端口sudo ufw allow 4000/tcpsudo ufw allow 4000

  2. 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.host0.0.0.0

暂无
暂无

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

相关问题 WebSocket连接失败:连接建立错误:net :: ERR_CONNECTION_TIMED_OUT - WebSocket connection to failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT WebSocket 连接到“ws://localhost:8080/”失败:连接建立错误:net::ERR_CONNECTION_REFUSED - WebSocket connection to 'ws://localhost:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED WebSocket 连接到“ws://..”失败:连接建立错误:net::ERR_CONNECTION_REFUSED - WebSocket connection to 'ws://..' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED WebSocket 连接到“wss://ip:8080/”失败:连接建立错误:net::ERR_CONNECTION_REFUSED - WebSocket connection to 'wss://ip:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED Websocket连接被拒绝。 WebSocket与'ws://127.0.0.1:2000 /'的连接失败:连接建立错误:net :: ERR_CONNECTION_REFUSED - Websocket connection refused. WebSocket connection to 'ws://127.0.0.1:2000/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED WebSocket连接到'ws://mydomain.com:8084 /?peer_id = 123'失败:连接建立错误:net :: ERR_CONNECTION_TIMED_OUT - WebSocket connection to 'ws://mydomain.com:8084/?peer_id=123' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT WebSocket与PHP的连接 - WebSocket connection with PHP PHP登录和会话建立 - PHP login and session establishment PHP whois 建立 - PHP whois establishment HTML5 / PHP WebSocket连接失败:WebSocket握手期间出错:意外的响应代码:200 - HTML5 / PHP WebSocket connection to failed: Error during WebSocket handshake: Unexpected response code: 200
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM