WebSocket reconnection
Hello everyone
I have a chat app with react native that use WebSocket . i have a problem when the connection is close i make new connection to the server
//close method
SocketContext.onclose = e => {
// connection closed
console.log("close socket");
SocketContext=null;
EventEmitter.emit("close", true);
};
// reopen method same as open socket function openSocket() { console.log("open socket");
return new Promise(function(resolve, reject) { SocketContext = new WebSocket(BASE_URL_SOCKET);
SocketContext.onopen = function() {
console.log("open ");
resolve(SocketContext);
};
SocketContext.onerror = function(err) {
reject(err);
};
}); } but here the problem the last socket doesn't killed in the app in every reconnection i have a socketId that increase and this make me a problem in the app i have this issue " could not invoke websocket module.connect " Can someone help how to reuse the same variable after close ? or how to kill the last socketConnection ? Thanks everyone
Sorry but this is issue tracker is only for bugs in the library. For general support please use another channel.