naderio / nativescript-socket.io

Fully-featured Socket.IO client implementation for NativeScript
The Unlicense
48 stars 21 forks source link

Disconnect issue #62

Open standevo opened 5 years ago

standevo commented 5 years ago

Hi, I have a strange behaviour when I try to manually disconnect the client. The disconnect event is firing on the server, also in logs I see that the client is disconnected but if I try to shutdown the server the client is trying to reconnect and fires with some interval error event. So, it turns out that the client was not successfully disconnected.

On client:

this.io = socketConnect(url, options);
this.io.on("connect", () => {})

...

this.io.on("error", (error: any) => {})

...

this.io.on("otherEvent", (data: any) => {})

...
// trying to disconnect manually
disconnect() {
    this.io.removeAllListeners();
    this.io.disconnect();
}

Server logs:

socket.io:client client close with reason transport close
socket.io:socket closing socket - reason transport close
socket.io-amqp removing P5ZCRTx9L28ThQGRAAAB from all rooms

Edit I think i figured it out. In client the socket debugging was enabled also was in wrong place. So it tried to reconnect.

 enableDebug(e => {
    console.log("Debug:sockets: ", e);
});