I am trying to write simple app that serves data using socket.io and node.js on server side. I would like to inform user if server is down (e.g. server serves webpage to the client and before any refresh server is halted). For now it results in browser giving following error:
GET http://localhost:8080/socket.io/?EIO=2&transport=polling&t=1409325689935-6 net::ERR_CONNECTION_REFUSED
I wasn't able to catch that event using socket.on('error'(...)) event and I would like to display some message as long as client fails to connect to server. Any ideas would be appreciated :) Code initializing socket is provided below:
socket = io.connect(document.domain, {
'sync disconnect on unload' : false
});
Couldn't you just check if the server serves you the .js file by doing something like this?
<script type="text/javascript" onload="loaded()" src="get_socket.js"></script>
function loaded(){
//this will only execute if the server is up
}