socket.io-client-java icon indicating copy to clipboard operation
socket.io-client-java copied to clipboard

Reconnect problem

Open AugustusCosta opened this issue 12 years ago • 4 comments

I have a service that when start:

private void connect() { LogUtil.i("Conectando com o SocketIO"); socketIO.connect(); }

and when finish:

private void disconnectIOSocket() { if ( socketIO != null ) { socketIO.close(); socketIO.disconnect(); } }

Everything are working great but when i stop the service and try to connect again nothing happen after the command:

socketIO.connect();

AugustusCosta avatar Aug 26 '14 18:08 AugustusCosta

Reconnecting sockets is not supported for now. Please see https://github.com/nkzawa/socket.io-client.java/issues/21

nkzawa avatar Aug 27 '14 15:08 nkzawa

Depending on your use case, setting forceNew might solve your problem:

IO.Options opts = new IO.Options();
opts.forceNew = true;

I think the issue is that closed sockets cannot be reused.

discretepackets avatar Sep 03 '14 09:09 discretepackets

Yes, you can create new sockets, but can't reuse closed sockets. thx, @discretepackets !

nkzawa avatar Sep 03 '14 10:09 nkzawa

Work for me. Thanks. Close this issue.

AugustusCosta avatar Sep 03 '14 16:09 AugustusCosta