You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TcpListener::incoming fails to receive new connections #888
Based on this question, it appears that there is some issue with the incoming stream on TcpListener.
use async_std::net::TcpListener;use futures::StreamExt;#[async_std::main]asyncfnmain(){let listener = TcpListener::bind("127.0.0.1:4444").await.unwrap();println!("Server listening on {}", listener.local_addr().unwrap());
listener
.incoming().for_each(|tcpstream| asyncmove{let tcpstream = tcpstream.unwrap();println!("Accepting from: {}", tcpstream.peer_addr().unwrap());}).await;}
[dependencies]
async-std = { version = "=1.6.4", features = ["attributes"] }
futures = "0.3"
This example does not print anything when new connections are made to that TcpListener, e.g. with nc 127.0.0.1 4444. My guess is that it is somehow failing to send notifications to the waker.
It works when fine rewritten to use accept in a loop.
I believe that this affects Tide as well, as we tried Tide a couple of days ago and it worked well, but no one in our team (Mac & Linux) can make it work today. It keeps frozen on accepting the connection:
Taking a look at this impl, it seems like it's calling accept, then dropping the future. My guess is that the new async-io release makes accept's future remove the registered waker in the destructor of the future.
@Darksonn can you file an issue on async-io about this? This doesn't seem like it should have been a patch release.
Though we can probably duplicate the AsyncRead impl from async_net::TcpStream to fix async-std's impl. Unfortunate, but that way we don't need to wait for a fix in async-io.
Activity
DavidBM commentedon Sep 28, 2020
I believe that this affects Tide as well, as we tried Tide a couple of days ago and it worked well, but no one in our team (Mac & Linux) can make it work today. It keeps frozen on accepting the connection:
jannik4 commentedon Sep 28, 2020
Same for me. Reverting from async-std 1.6.4 to 1.6.3 fixed it
yoshuawuyts commentedon Sep 28, 2020
Hi, thanks for the report! I think there may be one of two causes for the issue here:
We should probably dig deeper and find out what's going on.
Darksonn commentedon Sep 28, 2020
Taking a look at this impl, it seems like it's calling
accept, then dropping the future. My guess is that the new async-io release makesaccept's future remove the registered waker in the destructor of the future.async-std/src/net/tcp/listener.rs
Lines 188 to 198 in e812663
In fact, async-io has had a commit with the message Unregister wakers if readable() or writable() is canceled since the latest release, so it sounds likely to me.
yoshuawuyts commentedon Sep 28, 2020
@Darksonn can you file an issue on
async-ioabout this? This doesn't seem like it should have been a patch release.Though we can probably duplicate the
AsyncReadimpl fromasync_net::TcpStreamto fix async-std's impl. Unfortunate, but that way we don't need to wait for a fix inasync-io.Darksonn commentedon Sep 28, 2020
Sure! Done in smol-rs/async-io#30.
yoshuawuyts commentedon Sep 28, 2020
[email protected]has been published with a fix!*: Bump async-std to v1.6.5
*: Bump async-std to v1.6.5 (#7306)
*: Bump async-std to v1.6.5 (#7306)
upstream patch fixes (#160)