Open geomaniac opened 6 years ago
Just tried with v0.3.0, but it shows the same behavior.
Did some further digging and I think this might be related to carllerche/mio#776.
If I activate env_logger with RUST_LOG=trace, the last thing that gets logged after the client is dropped is
"TRACE 2018-06-27T07:04:55Z: mio::sys::windows::tcp: cancelling active TCP read"
(from mio/sys/windows/tcp.rs#L637).
Not sure if there is anything that can be done from grpc-rust (or rather rust-http2) to circumvent this issue.
tokio 0.3 has been released and it includes mio 0.7. Updating tokio (and mio) might help fix issue.
On Windows the GRPC client doesn't close its opened TCP connections on drop, only after the client process ends.
Trying to reproduce this, I created a slightly modified version of the hello world example client code. Here a new GRPC client is created once per iteration in a loop, sends a HelloRequest and is dropped at the end.
The modified example can be found at https://github.com/geomaniac/hello_world_grpc. The modified client code is in client.rs.
Now, starting the server and letting the client iterate three times, we can see the following on Windows or Linux.
On Windows
Before first iteration:
After three iterations:
The "ESTABLISHED" connections will only end, if we exit the client process. Otherwise they will remain open forever and new iterations create additional connections.
On Linux
Before first iteration:
After three iterations:
The "TIME_WAIT" connections will end after about 60 seconds.
I would expect that the GRPC client also closes its connections on Windows, when it is dropped.