ws
带模块的节点服务器代码:
show = console.log
WS = require('ws').Server
wss = new WS port: 8080
wss.on 'connection', (ws) ->
show 'a connection'
ws.on 'message', (message) ->
show 'received: %s', message
ws.send 'something'
我可以通过在同一台服务器上运行下面的代码来连接到 websocket,它给出了"a connection"
:
WS = require 'ws'
ws = new WS 'ws://localhost:8080'
但是当我从浏览器运行这些代码行时,没有响应:
s = new WebSocket('ws://184.82.253.196:8080');
s.send('nothing');
什么问题,我该如何解决?