I am playing around with node.js and socket.io-client. I am trying to connect to a channel that does not exist in order to trigger the event \'connect_failed\' (as specified
From the documentation:
connect_failed
Fired when the connection timeout occurs after the last connection attempt. This only fires if the connectTimeout option is set. If the tryTransportsOnConnectTimeout option is set, this only fires once all possible transports have been tried.
So this event fires only if the connectTimeout option is set (the implementation for that is here: https://github.com/LearnBoost/socket.io-client/blob/master/lib/socket.js#L223-245 ).
So what you should do different in your code is:
io.connect('http://localhost:4000/news', { 'connect timeout': 5000 });
// set connect timeout to 5 seconds