The code of Node server with ws
module:
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'
I can connect to websocket by running the code below on the same server,
and it gives out "a connection"
:
WS = require 'ws'
ws = new WS 'ws://localhost:8080'
But when I run these lines of code from browser, there's no respose:
s = new WebSocket('ws://184.82.253.196:8080');
s.send('nothing');
What's problem, how can I fix it?
Websocket server start listening only
127.0.0.1
by default. Use this code to start listen all interfaces.