boris-sinyapkin / lurk

Lightweight implementation of a SOCKS5 proxy built on async Rust
0 stars 0 forks source link

Shutdown connections gracefully #9

Closed boris-sinyapkin closed 6 months ago

boris-sinyapkin commented 7 months ago

Lurk started to decline incoming connections with the following error:

[lurk::server] Error while accepting the TCP connection: Too many open files (os error 24)

It seems some connections isn't closed properly thus newly connected clients can't be served.

boris-sinyapkin commented 7 months ago

To reproduce add the proxy to the Telegram. It seems Telegram is flooding the server with "healthcheck" request thus making it unresponsive due to plenty of opened and not closed connections ...

boris-sinyapkin commented 7 months ago

It turned out as we can't limit TCP connections from Tokio side, so need to implement custom limiter.

boris-sinyapkin commented 7 months ago

Lurk leaves connections with FIN_WAIT status. Need to investigate.

boris-sinyapkin commented 6 months ago

It seems https://github.com/boris-sinyapkin/lurk/commit/63e435bb7b68c75c527d89d2d586f83154a535d1 fixed the issue. As this affected error-handling during relay request, server won't send redundant data to client hence the connections will be closed properly.