Description
Hi, I've been using hyper 0.12 to talk to my local docker daemon and observed my program gets stuck during start up at a very low probability. I managed to minimize the reproducing code to the following piece but had no idea at all why this happens. The phenomenon is that running the following code after setting up the docker daemon to talk via tcp instead of unix socket, which is default, eventually makes the whole program stuck after a certain period of time. (In my Ubuntu on VMware on MacBookPro 2020 it takes less than a minute) I know that my software stack is quite outdated, but to make sure this problem is entirely fixed I think I need find out the actual cause. Is this a bug in hyper or is my usage simply incorrect?
How to reproduce
Before running the code one needs to set up the docker daemon to talk tcp. (I found this instruction https://gist.github.com/styblope/dc55e0ad2a9848f2cc3307d4819d819f helpful).
// [dependencies]
// futures = "0.1"
// hyper = "0.12"
// tokio = "0.1"
use futures::{Future, Stream};
fn main() {
let client = hyper::Client::new();
let mut runtime = tokio::runtime::Runtime::new().unwrap();
for i in 0.. {
println!("{}", i);
let client = client.clone();
let future = client
.get("http://localhost:2375//events".parse().unwrap()) // get 301 response and discard it; appearently meaningless code but removing this line changes the behavior.
.and_then(move |_resp| client.get("http://localhost:2375/events".parse().unwrap()));
let res = runtime.block_on(future).unwrap(); // this doesn't return at a low probability
let future = res.into_body().for_each(|_| Ok(()));
runtime.spawn(future.map_err(|_| ()));
}
}