programatik29 / axum-server

High level server designed to be used with axum framework.
MIT License
166 stars 54 forks source link

Acceptor errors are ignored #90

Open jparris opened 8 months ago

jparris commented 8 months ago

Hi there,

I wrote a custom acceptor that enforces client hostname checking during mTLS. I noticed in serve that errors from the acceptor are ignored, leading the the socket being closed with out reporting an error back to the client. It would be helpful to report these errors back to the client before closing the connection.

serve in server.rs

 tokio::spawn(async move {
     if let Ok((stream, send_service)) = acceptor.accept(addr_stream, service).await   
     // ^^^^ maybe match on the result and write the error down the socket before closing the connection.
.....
programatik29 commented 7 months ago

In the case of an error, there is no way to access the socket to write to.

You should be able to write the error to the socket before returning an error from acceptor.