Socket.IO-client.java disconnect and reconnect reconnect
I am using socket.io-client.java and socket.io 1.2.1 on my server node for my android project and the android socket connects to the server fine, but after a few minutes it automatically disconnects and reconnects again. I can't figure out the problem, can anyone help me?
I am using the libraries socket.io-client-0.1.1.jar, engine.io-client-0.2.1.jar and Java-WebSocket-1.3.0.jar.
here is the java code
private void socketTest() throws URISyntaxException{
socket = IO.socket("http://192.168.169.2:8082");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
socket.emit("test", "awesome");
}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {}
});
socket.connect();
}
and here is the server side code
io.on('connection', function (socket) {
console.log('a user connected');
socket.on('disconnect', function () {
console.log('user disconnected');
});
socket.on('test',function(msg){
console.log("This is "+msg);
});
});
and here is a screenshot of the log
source to share
I have the same problem in the client library socket.io-client:1.0.0
in my Android project, but after the version socket.io
has changed to 5.0, it works fine. You may be prompted for below client version.
compile('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}
source to share