netty-socketio
netty-socketio copied to clipboard
Connect disconnect loop nettysocketio / socketio-client java
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
this loop happen with socket.io nodejs server ?
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 I have encountered the same problem, did you finally solve it?
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 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?
I'm facing the same issue with the latest version (1.7.14)
Any news on this issue ? I am facing it as well but downgrading to 1.7.8 doesn't seem to work