Backlog option/example for connections/sockets
gheorghitamutu opened this issue · 7 comments
Hello,
Uvicorn has a --backlog
setting that limits the number of connections accepted from a socket: https://www.uvicorn.org/settings/#resource-limits.
--backlog <int> - Maximum number of connections to hold in backlog.
Is there a way to do the same in salvo
?
It should not be supported at this stage。
Is there any chance for this to be implemented in the future or is this a choice that has already been made?
The current TcpListener is implemented based on tokio's TcpListener, which does not seem to be able to set backlog.
If it is to be supported, should another new Listener be implemented based on socket2?
Please check branch socket2.
Enable feature ·socket2` in Cargo.toml
[dependencies]
salvo = { workspace = true, features = ["socket2"] }
And set it in your code:
let acceptor = TcpListener::new("0.0.0.0:5800").backlog(128).bind().await;
Could you please help me check if this is correct? @gheorghitamutu
Hello, @chrislearn,
#812 with using socket2
feature is indeed exposing what I was missing - it works.
Can I assume that it will soon be merged to the main branch / a new crate version will be released exposing this feature?
Thank you for solving this so fast!!
Released
Thanks!