netty-socketio icon indicating copy to clipboard operation
netty-socketio copied to clipboard

Connect disconnect loop nettysocketio / socketio-client java

Open AhmedX6 opened this issue 8 years ago • 7 comments

Hello,

I'm facing a big problem and I don't know how to resolve it. I tried so many things.. I'm using netty-socketio to create a socket server on Android, and socket.io-client-java for client side.

Here is the code of socket creation (client side) : public SocketCommunication(String ip) { //ip is generally : 192.168.1.1 follow with the port if (socket == null) { try { IO.Options opts = new IO.Options(); opts.forceNew = true; opts.reconnection = true; socket = IO.socket(ip, opts); socket.connect(); } catch (URISyntaxException e) { e.printStackTrace(); } } } public static Socket getInstance() { return socket; }

And here is the code of listnening socket creation (server side) : private static SocketIOServer server; public SocketServer() { openSocket(); } public static SocketIOServer getInstance() { return server; } private void openSocket() { if (server == null) { Configuration config = new Configuration(); config.getSocketConfig().setReuseAddress(true); config.setPort(5902); server = new SocketIOServer(config); server.start(); } }

Then I have the addConnectionListener of netty socket to check if the client connect works. Everything works but after 1 min the client disconnects unexpectedly. And connect/disconnect loop starts. I work with last version of netty socket 1.7.11 and socketio version 0.7.0.

Please can you help me I'm stuck

Thank you

AhmedX6 avatar Aug 09 '16 17:08 AhmedX6

this loop happen with socket.io nodejs server ?

amincheloh avatar Aug 10 '16 02:08 amincheloh

No it's a java server. I have two android application. One acting as a client, the other is a server.

I am testing my apps on two devices, one with Android 6.0.1 API 23 and the other device is on Android 4.4.3 API 19. When I install the server APK on the Android 6.0 and the client on the 4.4.3. The socket.connect() works but when I switch it fails...

I think I have an idea... I tried to use AndroidAsync Koush library for sockets. I created a client socket and a server socket. When I install the server APK on the Android 6.0 and the client on the 4.4.3, there is no problem, server can emit and client receives.. But in the other way I have an exception "java.util.concurrent.TimeoutException". I think that's why I got the first problem I was talking about earlier. Someone can help me ?

Thank you

AhmedX6 avatar Aug 10 '16 07:08 AhmedX6

@AhmedX6 I have encountered the same problem, did you finally solve it?

lch277 avatar May 04 '17 08:05 lch277

Hello Ich277. I did not solve the problem with netty socket 1.7.11... I use 1.7.8 version and it works well. The problem comes from the 1.7.11 version...

AhmedX6 avatar May 04 '17 08:05 AhmedX6

@AhmedX6 Yeah, The 1.7.8 version works like a charm. Thank you very much. I have been stuck here for two days

@amincheloh Could anyone fix this in the latest version?

lch277 avatar May 04 '17 09:05 lch277

I'm facing the same issue with the latest version (1.7.14)

prasadlakmal avatar Mar 26 '18 10:03 prasadlakmal

Any news on this issue ? I am facing it as well but downgrading to 1.7.8 doesn't seem to work

tristan-elain-cbp avatar Oct 01 '20 15:10 tristan-elain-cbp