How do I detect if the server is offline, or for some other reason cannot connect. My code looks something like this.
this.socket = io.connect(connectionInfo, {
reconnect:false
});
It does not throw any error, so a try/catch clause is not working.
If your server is offline and Client tries to connect use:
So Client knows he can not reach the server.
Since the 1.0 update, connection events are different. read this page for more info: http://socket.io/docs/migrating-from-0-9/
In my case, i could detect a connection error like so:
Use
this.socket.on("connect")
to catch connection eventsthis.socket.on("disconnect")
to catch disconnection eventsthis.socket.on("connect_failed")
to catch failed connection attemptsUse this.socket.io.on("connect_error", callback) to catch if the server is offline.
You can find all events, at https://github.com/LearnBoost/socket.io/wiki/Exposed-events