Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection pool fails if server closes connection #10

FauxFaux opened this issue Sep 9, 2019 · 1 comment


Copy link

commented Sep 9, 2019

The connection pool does not cope with HTTPS servers closing the connection, due to rustls being mean.

If I make a request, then wait for the connection to time out, then make another request, I see the error: BadStatus. This means that every other request I make fails.

This test fails, because is currently running an nginx with a keepalive_timeout of 2s:

fn connection_reuse() {
    let agent = ureq::Agent::default().build();
    let resp = agent.get("").call();

    // use up the connection so it gets returned to the pool
    assert_eq!(resp.status(), 200);
    resp.into_reader().read_to_end(&mut vec![]).unwrap();

    // wait for the server to close the connection

    // try and make a new request on the pool
    let resp = agent.get("").call();
    if let Some(err) = resp.synthetic_error() {
        panic!("boom! {:?}", err);
    assert_eq!(resp.status(), 200);

nginx defaults to 75s, some servers have much longer timeouts, some much shorter, but everyone will eventually see this problem.

I was hoping that attempting a write during send_prelude would trigger the retry code, #8, but this does not help.

I do not see a way to fix this right now. A read(&mut [])? in send_prelude doesn't trigger it, and we aren't expecting any data to be readable at that point, so clever buffering wouldn't help.

FauxFaux added a commit to FauxFaux/unsnap that referenced this issue Sep 9, 2019
ureq hacks
1) pick up this patch: algesten/ureq#9
2) avoid connection pool as closing connections barfs it: algesten/ureq#10

This comment has been minimized.

Copy link

commented Sep 11, 2019

The connection pool overall is a bit under tested. I'm all open to suggestions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.