Closed SmnTin closed 1 year ago
It turned out that TcpListener::from_std
requires that the listener is already in non-blocking mode. It was hard to find since without tungstenite
, everything worked just fine.
Setting the std
listener to a non-blocking mode before wrapping it into the tokio
listener resolves the issue.
Yes, we do not change mode of the listener since we can't make any assumptions about its interface except that it can send and receive.
main.rs
:Cargo.toml
:rustc
version:rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
OS:macOS Ventura 13.4.1 (c)
Expected behavior
The client in a separate thread connects to the server and receives a message every 50 ms. After 500 ms, the server and the client shut down.
The log looks like:
Actual behavior
However, the real execution prints:
The following happens:
TcpListener::accept
to accept the next client, after which everything blocks.Instrumenting with
tokio-console
confirms that the executor is blocked.