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

Handling timeouts when the request and response body size varies #870

Open
dae opened this issue Mar 30, 2020 · 1 comment
Open

Handling timeouts when the request and response body size varies #870

dae opened this issue Mar 30, 2020 · 1 comment

Comments

@dae
Copy link

dae commented Mar 30, 2020

Hi there,

Firstly, thank you for all of your hard work on this crate - it is a pleasure to use.

My use case is posting requests to a remote API, where the request body and response body can vary widely, from a few kilobytes to tens of megabytes. This makes it difficult to determine an appropriate timeout for each request. I thought about setting the request timeout based on the size of the request body and some conservative estimate of a user's line speed, but it looks like the timeout that is set on the request will also apply as the response body is being read out (#502). If I've read the code correctly I could work around that by streaming the body and applying my own timeout, but I find myself wondering if there is an easier way.

Is there a way to specify a timeout on the socket read/write instead? In this case I'm not so concerned with the total amount of time taken, but simply if progress is being made or not, as that way I can avoid connections getting stuck, while not timing out unnecessarily for users with slow connections. Any suggestions you might have would be greatly appreciated.

@dae
Copy link
Author

dae commented Aug 21, 2020

The hyper-timeout crate appears to enable this, but to add it in client code, reqwest would need to support a generic impl Connector being passed in, instead of hard-coding the use of Connector. Is there any interest in merging such an approach? For now I'll just use a custom version, but it would be great if this didn't require forking in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant