Expected behavior: WebServer.close() closes the web socket server directly.
Actual behavior: WebServer.close() waits until its clients to be disconnect by themselves.
When call the WebServer.close() method and there's a client who is connecting to the WebServer, the method call would be completed until the client disconnects network connection with the server by itself. Therefore, it remained clients do not disconnect their connections by themselves, the WebServer.close() method would not be completed and fall into the forever sleep.
Code occuring the bug
const PORT = 10101;
export async function test_web_server_close(): Promise<void>
{
let server: WebServer<null, null> = new WebServer();
await server.open(PORT, acceptor => acceptor.accept(null));
let connector: WebConnector<null, null> = new WebConnector(null, null);
await connector.connect(`ws://127.0.0.1:${PORT}`);
server.close().then(() =>
{
// it would be shown after 5,000 milliseconds later
console.log("WOW");
});
await sleep_for(5000);
await connector.close();
}
Summary
WebServer.close()
closes the web socket server directly.WebServer.close()
waits until its clients to be disconnect by themselves.When call the
WebServer.close()
method and there's a client who is connecting to theWebServer
, the method call would be completed until the client disconnects network connection with the server by itself. Therefore, it remained clients do not disconnect their connections by themselves, theWebServer.close()
method would not be completed and fall into the forever sleep.Code occuring the bug