Replies: 7 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Hello @e3dio
and to shutdown i used this simple get:
after calling shutdown on that token i can no longer reach http which is expected but i can still connect to ws socket . is that expected?
|
Beta Was this translation helpful? Give feedback.
-
@jcherrabi I don't see you closing any websockets in your shutdown code, that would probably fix your issue #575 |
Beta Was this translation helpful? Give feedback.
-
Just to expand on what is being said here for HTTP connections: in the case of HTTP connections that are using Keep Alive (sending a This means that uWS cannot gracefully close a long-lived HTTP connection later like it can with a WS connection. The following code will cause the process to run indefinitely, even after sending SIGINT (Ctrl + C) to the server, as the client keeps the connection open even after us_listen_socket_close as closed. There is no way for the server to keep track of the open HTTP connection to gracefully dispose of them. // server.js
// run as `node server`
const {App, us_listen_socket_close} = require('uWebSockets.js');
let _listenSocket = null;
App().any("/*", (res) => {
res.end("hello"); // don't send `end(_, true)` because we _want_ to allow keep alive connections.
}).listen(5555, (listenSocket) => {
_listenSocket = listenSocket;
console.log("listening...");
});
process.on("SIGINT", () => {
us_listen_socket_close(_listenSocket)
_listenSocket = null;
console.log("Listen socket closed, waiting for process to exit...");
});
I couldn't find a way to work around this that doesn't involve For WS connections it's easy, as we already have to keep track of those, so on shutdown we can iterate over them and close them all. For HTTP I don't see how it is possible. |
Beta Was this translation helpful? Give feedback.
-
If you add |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Http timeout is 10 seconds, is not determined by what client sends in header, might be short enough for you https://github.com/uNetworking/uWebSockets/blob/master/src/HttpContext.h#L44 |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
when i call
us_listen_socket_close
it seems to close the http/https socket but not the websockets sonnections, is this the correct behavior ? and i should handle closing down the websockets separately?thanks,
Jay
Beta Was this translation helpful? Give feedback.
All reactions