socket.io-android-chat icon indicating copy to clipboard operation
socket.io-android-chat copied to clipboard

Timout Issue

Open DastanIqbal opened this issue 10 years ago • 3 comments

Not getting timeout event some times in call() Emitter.Listener. but its coming in Manager open() method in timeout

if (Manager.this._timeout >= 0) {
                    final long timeout = Manager.this._timeout;
                    logger.fine(String.format("connection attempt will timeout after %d", timeout));

                    final Future timer = getTimeoutScheduler().schedule(new Runnable() {
                        @Override
                        public void run() {
                            EventThread.exec(new Runnable() {
                                @Override
                                public void run() {
                                    logger.fine(String.format("connect attempt timed out after %d", timeout));
                                    openSub.destroy();
                                    socket.close();
                                    socket.emit(Engine.EVENT_ERROR, new SocketIOException("timeout"));
                                    self.emitAll(EVENT_CONNECT_TIMEOUT, timeout);
                                }
                            });
                        }
                    }, timeout, TimeUnit.MILLISECONDS);

                    Manager.this.subs.add(new On.Handle() {
                        @Override
                        public void destroy() {
                            timer.cancel(false);
                        }
                    });
                }

DastanIqbal avatar Aug 25 '15 05:08 DastanIqbal

Sorry I couldn't understand the problem. Can you explain the details of the issue?

nkzawa avatar Aug 25 '15 05:08 nkzawa

Once I connect to my server using Socket socketio=IO.socket(ip:port) and trying to connect other server using same instance of socketio. sometimes its work and coming in above Manager open() method in timeout section. and sometimes its not.

And If I want to reconnect to server so which method I need to use. I can use same instance of Socket Right?

DastanIqbal avatar Aug 25 '15 11:08 DastanIqbal

Am I correct that you mean to connect to different servers by calling IO.socket(ip:port) twice? That should work. I'm not sure about the timeout, but you can just call socket.connect(); to reconnect.

nkzawa avatar Aug 25 '15 12:08 nkzawa