3

I'm using socket.io to establish communication between server and html5 client and everything is working fine on desktop and safari on iPhone simulator. The client fails to establish connection though when I try to run it from any iOS or even android device.

Using web inspector, I was unable to output console error on my ios7 device, but managed to get a list of resource with an item under XHR attempting to connect to the server ip address and fails after about 2 to 3 minutes (turns red)

My iOS device is iOS 7.03 (iPhone 4), and I'm using node v0.10.21, and socket.io v0.9.16 I'm also using ip addresses to connect so I'm not sure if there is a same domain restriction that applies

The following are the relevant parts from the client:

<script src="http://xx.xx.xx.xx:port/socket.io/socket.io.js"></script>
var socket =  io.connect("http://xx.xx.xx.xx:port");

socket.on('connect', function() {
    console.log("connected");
}

socket.on('disconnect', function() {
    console.log("disconencted");
}

socket.on('message', function(data) {
    console.log("rcved:"+ data*emphasized text*);
}

server

var io = require('socket.io').listen(12321).set('log level', 0);
var ConnectionHandler = require('./handler.js');


io.sockets.on('connection', function (socket) {
new ConnectionHandler(socket);
});

Might I also point out that when I enable full logging on server side, no connection are attempt for a connection is made from mobile devices, just the desktop devices and iOS simulator.

Any suggestions on a fix or how to pursue a solution to this problem is appreciated

4

1 回答 1

1

原来是防火墙问题:|

台式电脑在 VPN 上,手机不在这解释了这个问题

我觉得很愚蠢,但我会把它留在这里,以防它帮助某人检查同样的问题

于 2013-11-10T17:01:36.530 回答