How to Reconnect to Socket Server ?
I have created one SocketIOServer in Java code which runs on specific ip and port I have also created client Socket. Connected it with the server and emitting one string with function .emit() Added one EventListener in Server which listens to one event and broadcasts it to all clients
Here is my Server Code
Configuration config = new Configuration();
config.setHostname("ec2-35-162-132-106.us-west-2.compute.amazonaws.com");
config.setHostname("192.168.1.3");
config.setPort(9097);
SocketIOServer server = new SocketIOServer(config);
server.start();
server.addEventListener("testData", String.class, new DataListener
Here is my client code
Socket socket = IO.socket("http://35.162.132.106:9097");
socket.emit("testData", "TestString");
socket.connect();
when i run my code, It runs perfect for some time after running it and suddenly gives the following error
[nioEventLoopGroup-3-1] ERROR com.corundumstudio.socketio.transport.PollingTransport - 71918f5c-b4b0-4333-a92a-bc0cf03d63c0 is not registered. Closing connection [nioEventLoopGroup-3-2] ERROR com.corundumstudio.socketio.transport.PollingTransport - 7d39dff6-e41c-4f61-9bba-024adc9e2686 is not registered. Closing connection [nioEventLoopGroup-3-1] ERROR com.corundumstudio.socketio.transport.PollingTransport - eb9d719f-889e-413b-9cb9-e755bbd59051 is not registered. Closing connection [nioEventLoopGroup-3-2] ERROR com.corundumstudio.socketio.transport.PollingTransport - 6d394eee-a4c5-4ace-877e-0146c9d4a90c is not registered. Closing connection [nioEventLoopGroup-3-1] ERROR com.corundumstudio.socketio.transport.PollingTransport - 63b866b3-6e51-4487-a715-d9b689878d9c is not registered. Closing connection
How to solve this issue ?
To reconnect socket :
IO.Options opts = new IO.Options();
opts.forceNew = true;
opts.reconnection = true;
Socket socket = IO.socket(SOCKET_URL, opts);
socket.connect();
Closed due to inactivity, please reopen if needed.