ws
モジュールを使用した Node サーバーのコード:
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');
何が問題なのですか、どうすれば修正できますか?