Poem/Tokio server freezes with CLOSE-WAIT sockets

This may not be the correct forum, but I haven't been able to locate a forum for web applications based on the poem-openapi flavor of the poem framework and uses the tokio runtime.

The problem is that during load testing with goose the server freezes after many sockets get stuck in the CLOSE-WAIT state. Usually 4,000 to 8,000 requests succeed before the web app freezes.

Any thoughts are appreciated. Here's how I initialize the server:

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
....
        poem::Server::new(
            TcpListener::bind(addr).rustls(
                RustlsConfig::new().fallback(
                    RustlsCertificate::new()
                        .key(std::fs::read(key)?)
                        .cert(std::fs::read(cert)?),
                ),
            ),
        )
        .name(SERVER_NAME)
        .idle_timeout(Duration::from_secs(60))
        .run(app)
        .await
....

Here's how one of the endpoints is defined:

#[OpenApi]
impl NewSshKeysApi {
    #[oai(path = "/tms/pubkeys/creds", method = "post")]
    async fn get_new_ssh_keys(&self, http_req: &Request, req: Json<ReqNewSshKeys>) -> TmsResponse {
        match RespNewSshKeys::process(http_req, &req) {
            Ok(r) => r,
            Err(e) => {
                // Assume a server fault if a raw error came through.
                let msg = "ERROR: ".to_owned() + e.to_string().as_str();
                error!("{}", msg);
                make_http_500(msg)
            }
        }
    }
}

2024-10-16T05:00:00Z

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.