Warp/Hyper/Tokio: long running async function

Hi,
I have an async function which downloads a big file. With reqwest it works. When I call the same function within warp in a 'handler' I get this error:

connection error: connection closed before message completed 

The download seems to be aborted after exactly 1 minute.

Any idea?

Best regards
gpf

In a warp handler? That means your task is aborted if whoever made that request closes the connection. Consider putting the download in a tokio::spawn to have it be a background task that isn't cancelled even if the request is cancelled.

Hi,
I'm relative new to warp (and Rust). I do not know how to put it an background task using tokio::spawn with warp. And I still wondering why the async function works in reqwest but not in warp. It seems that warp (or hyper) cancel the asnc fn after 1 minute. Any idea regarding this 1 minute? This is somehow suspicious.
Best regards
gpf

Hi,
I want to download a file form a S3 bucket. Just found a stackoverflow comment, that there is some 60 seconds timeout regarding S3. But why reqwest works and warp not?
Best regards
gpf

Hi Alice,
you wrote:
That means your task is aborted if whoever made that request closes the connection.

Will investigate into this suggestion. Thank you very much for this.
Best regards
gpf

tokio::spawn(async move {
    your background task goes here
});

You should elaborate on what you mean by this. Reqwest is a library for sending a web request to someone else, and warp is a library for creating a server that can receive web requests from others, so they are far from directly interchagneable. Are you using reqwest inside warp, or something else? That's what I assumed from reading your question.

@alice First: Sorry for the late response.

Your remarks were very helpful. The client calling tokio was a Java program. This was really helpful:
That means your task is aborted if whoever made that request closes the connection.
The connection was closed by the Java program.

Thank you very much!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.