ws icon indicating copy to clipboard operation
ws copied to clipboard

WebSocket reconnection

Open issamabdelkrim opened this issue 7 years ago • 1 comments

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

issamabdelkrim avatar Oct 23 '19 16:10 issamabdelkrim

Sorry but this is issue tracker is only for bugs in the library. For general support please use another channel.

lpinca avatar Oct 23 '19 18:10 lpinca