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

Error connection closed before message completed after 60s #1082

Open
joshua-tree-19231 opened this issue Dec 12, 2023 · 2 comments
Open

Error connection closed before message completed after 60s #1082

joshua-tree-19231 opened this issue Dec 12, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@joshua-tree-19231
Copy link

joshua-tree-19231 commented Dec 12, 2023

Version

v0.3.6

Platform

Linux backend1 5.10.0-17-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 GNU/Linux

Cloud provider: OVH

Description

Got error "connection closed before message completed" from hyper::server::server::new_svc when I make a request that's long (>60s), coming from:

https://github.com/hyperium/hyper/blob/d77c2599bc023b258b90a17f5b633c8b7b0cbd4b/src/server/server.rs#L765

I tried this code:

pub fn do_my_thing() -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
	warp::path!("v0" / "do_my_thing")
		.and(warp::post())
		.and(warp::body::content_length_limit(1024 * 16))
		.and(warp::body::json())
		.and_then(do_my_thing_handler)
		.with(warp::log(LOG_TARGET))
		.recover(errors::handle_rejection)
}

// Then:
warp::serve(do_my_thing())

The thing is, the do_my_thing_handler can take anywhere from 2s to 90s. And when in takes too long (>60s when counting in my head), I don't get any response, and instead get the above error "connection closed before message completed".

On the client using Postman, I get Error: socket hang up. With curl, it's Empty reply from server

I expected to see this happen: [explanation]

Return the response in any case, when the handler takes 2s or 60s.

Instead, this happened: [explanation]

I get an error on my client:

  • curl: 52 empty reply from server
  • Postman: socket hang up

See logs (also see times).

2023-12-12T19:34:02.815976Z DEBUG hyper::proto::h1::io: parsed 10 headers
2023-12-12T19:34:02.816018Z DEBUG hyper::proto::h1::conn: incoming body is content-length (92 bytes)
2023-12-12T19:34:02.817115Z DEBUG hyper::proto::h1::conn: incoming body completed 
-- snip start --
do my own thing, takes ~60s
-- snip end --  
2023-12-12T19:35:02.802905Z DEBUG hyper::server::server::new_svc: connection error: connection closed before message completed
2023-12-12T19:35:03.236297Z DEBUG hyper::proto::h1::io: parsed 0 headers
2023-12-12T19:35:03.236329Z DEBUG hyper::proto::h1::conn: incoming body is empty

The response is correct when my own handler does its job in less than 60s.

Other notes

I also checked hyperium/hyper#2136, but it seems like the other issue is more on the client side, e.g. using reqwest.

@joshua-tree-19231 joshua-tree-19231 added the bug Something isn't working label Dec 12, 2023
@deadash
Copy link

deadash commented Dec 25, 2023

I have the same problem using reqwest

@wisehuang
Copy link

Encountering the same issue when using both reqwest and surf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants