mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

Checking if the client connected successfully #222

Closed pramodbms closed 9 years ago

pramodbms commented 9 years ago

Hi,

On the client side, is it possible to check if the connect() call was successful?

var iosocket = io.connect('http://localhost:8081');

I see that the iosocket has few attributes : connected, disconnected, readyState.

But the values of these variables seems to be the same even when the io.connect() failed. It always shows up as:

connected : false, disconnected:true. iosocket.io.readyState="opening" .

My use case is to check if the connect() was successful and if it failed, to handle the error gracefully on the client side.

pablojr commented 9 years ago

I guess you may want to check for the onConnect() event (when client gets connected) or onError() event for any error. Please be advised that your question is related to socket.io protocol, not netty-socketio specific, so you may want to double check in another forum.

pramodbms commented 9 years ago

Ok.

solved this issue by registering a handler for "connect_error" event.