我正在尝试使用带有gos/web-socket-bundle的rachet服务器在php中创建套接字连接。配置集是
gos_web_socket:
server:
port: 1337 #The port the socket server will listen on
host: 127.0.0.1 #The host ip to bind to
pushers:
zmq:
default: true
host: 127.0.0.1
port: 5555
persistent: true
protocol: tcp
我可以使用php console gos:websocket:server
启动服务器,然后服务器启动
08:37:41 INFO [websocket] Starting web socket [] []
08:37:41 INFO [websocket] ZMQ transport listening on 127.0.0.1:5555 [] []
08:37:41 INFO [websocket] Launching Ratchet on 127.0.0.1:1337 PID: 19774 [] []
但是我无法从javascript连接到套接字
var websocket = WS.connect("ws://127.0.0.1:1337");
WebSocket connection to 'ws://127.0.0.1:1337/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
netstat -l </ em> 结果
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:5555 *:* LISTEN
tcp 0 0 localhost:1337 *:* LISTEN
我正在使用symfony 3.2 php 7.0的流浪汉上运行该应用程序。
关于为什么不通过JS建立连接的任何想法?