Thursday, 15 March 2012

sockets - server-to-server node.js ws websocket -



sockets - server-to-server node.js ws websocket -

i have 2 node.js apps on sever , wan't send sever-server messages between them. testing running first app first , starting second.

app 1: see console message opened 1 don't see hi 2

var websocket = require('../node_modules/ws'); var ws = new websocket('ws://127.0.0.1:8008'); ws.on('open', function() { console.log('opened 1'); ws.on('message', function(_){ console.log(_); }); ws.send('hi 1'); });

app 2: see console message opened 2 don't see hi 1

var websocketserver = require('../node_modules/ws').server , wss = new websocketserver({port: 8008}); wss.on('connection', function(ws) { console.log('opened 2'); ws.on('message', function(_) { console.log('received:',_); }); ws.send('hi 2'); });

why wont talk to/hear each other?

node.js sockets

No comments:

Post a Comment