Closed christophsaile closed 2 years ago
Hello, stop is async. shouldn't you wait for the callback before starting it up again ?
function onStop(addr: string, _port: number) {
startUpServer(_port);
}
Hey, thanks for your answer. Yes you are right with the callback. I tested your solution but the problem still exists.
I get the following error: "Stopped listening on :::8000. Reason: Address already in use"
I created a test repo to show you the bug: https://github.com/christophsaile/websocket-issue-test
I think the problem is: if you reopen the app, the success callback of the wsserver.stop function doens´t get triggert because there is no port open, but if you then call the wsserver.start function in the failure callback, you get the error message from above. This means that the port is somehow still not closed?
Thanks in advance :)
Found a potential issue: Port stays bound after calling WebSocketServer.close
.
Also, TooTallNate's server does not seem to do anything to unbind its port: wsf.close() //Nothing to do for a normal ws factory
Are you able to investigate those 2 points please?
Yes I can have a look on it, but it will probably take some time. Currently this bug has not top prio on my study project. I need to fix some other stuff first :)
I am facing the same problem. Somebody help me!
I solved the problem. net/becvert/cordova/WebSocketServerPlugin.java in node_modules. Add At line 157 newserver.setReuseAddr(true)
And save then npx cap sync It works fine !!
Hello :),
just recently I noticed an issue with closing the wsserver. If I do the following steps I get an error:
This bug only happens if I close the app, reopen the app and call the restartServer function in less then ~ 1-3 min. My wsserver.start - function is nested in the startUpServer function and is the same as in the docs.
Is it possible that the server is somehow still open, even though I closed the app with the taskmanager? Thanks in advance
restartServer function:
Console.log of the error