I am using socket io with node to manage an chat application
I can easily connect to my socket well , however , when I connect from other other machine , the client do not recive anything .
in other machine , there is no antivirus and firewall disabled . ( I use google chrome and opera and windows 7 )
something that is really interesting is that I can connect to socket with my mobile well !
when that machine connect to system , I can see this debug in console
info - socket.io started
debug - served static content /socket.io.js
debug - served static content /socket.io.js
debug - client authorized
info - handshake authorized gu63jD6tYNPCf7JO72U0
debug - setting request GET /socket.io/1/websocket/gu63jD6tYNPCf7JO72U0
debug - set heartbeat interval for client gu63jD6tYNPCf7JO72U0
debug - client authorized for
debug - websocket writing 1::
**debug - websocket writing 5:::{"name":"ready","args":[{"msg":"hi"}]}**
debug - setting request GET /socket.io/1/xhr-polling/gu63jD6tYNPCf7JO72U0?t=1374596975155
debug - setting poll timeout
debug - discarding transport
debug - cleared heartbeat interval for client gu63jD6tYNPCf7JO72U0
debug - setting request GET /socket.io/1/jsonp-polling/gu63jD6tYNPCf7JO72U0?t=1374596985158&i=0
debug - setting poll timeout
debug - discarding transport
debug - clearing poll timeout
I use this to connect to my site :
var socket = io.connect('192.168.1.101:900');
the machine do not get 404 not found , or error , just the methods did not fire...
as you can see , the client should receive ready , but it do not get , where is the problem ?
the server source :
var express = require('/usr/local/lib/node_modules/express'),
app = express()
, http = require('http')
, server = http.createServer(app)
, io = require('/usr/local/lib/node_modules/socket.io').listen(server);
// listen for new web clients:
server.listen(900, function() {
//console.log(this);
});
// routing
app.get('/', function(req, res) {
res.end('It works');
});
io.sockets.on('connection', function(socket) {
socket.emit('ready', {msg: 'hi'});
}
Client
var socket = io.connect('192.168.1.101:900');
console.log('connecting');
socket.on('error', function(data) {
console.log(data || 'error');
});
socket.on('connect_failed', function(data) {
console.log(data || 'connect_failed');
});
// on connection to server, ask for user's name with an anonymous callback
socket.on('connect', function() {
alert('work');
});
socket.on('ready', function() {
alert('work');
});