web.js: disconnect not finding open socket
Closed this issue · 3 comments
Hey @mia-z, Thanks for this wonderful capacitor plugin!
I implemented it using the new web.js integration and found that the disconnect function is always failing: https://github.com/mia-z/capacitor-websocket/blob/main/src/web.ts#L80.
Do you have an idea why this might be the case and are you experiencing the same?
Glad you're enjoying it!
I haven't extensively tested the web version since I mainly use the ios/android implementations.
The only reason I could see it failing is if the socket is somehow null before the disconnect happens. Are you getting the error Couldnt get socket with name: {name}
?
Oh, no I am getting an error during disconnect: Error: Tried to disconnect an already disconnected socket!
.
So the socket seems to exist inside the array but hasnt the connect flag set... which is strange because it still receives messages so it is definitely connected.
@mia-z Could it be that this.sockets[t].socket.connected
is never set to true after socket connected?