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

Is there a way to set retry and max retry times for client request ? #2935

Closed
mingmwang opened this issue Aug 5, 2022 · 3 comments
Closed

Comments

@mingmwang
Copy link

mingmwang commented Aug 5, 2022

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Is there a way to set the retry times for failed client requests?

And regarding the client connection settings, besides the keep-alive settings, is there a way to set an idle time to close the connection? We want to reuse the connection as much as possible, but if there is no real traffic(except for pings) within a time(say 30 mins), we want the connection to be closed.

let endpoint = tonic::transport::Endpoint::new(dst)?
    .connect_timeout(Duration::from_secs(20))
    .timeout(Duration::from_secs(20))
    .tcp_keepalive(Option::Some(Duration::from_secs(3600)))
    .http2_keep_alive_interval(Duration::from_secs(300))
    .keep_alive_timeout(Duration::from_secs(20))
    .keep_alive_while_idle(true);

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@mingmwang mingmwang added the C-feature Category: feature. This is adding a new feature. label Aug 5, 2022
@mingmwang
Copy link
Author

In Netty, there is an IdleStateHandler which can trigger event to close the idle tcp connections. Not sure whether Hyper has a way to achieve the same effects or not.

@seanmonstar
Copy link
Member

hyper does not retry requests. Looks like you're using tonic, which integrates with tower. You can use the tower::retry middleware to do so. Define a Policy that describes what responses/errors are safe to retry, and I recommend using the Budget in the same module to implement a limit, instead of a simple counter.

@seanmonstar
Copy link
Member

We have an issue of the ways we're making generic retries better, you can follow along (and give feedback) here: tower-rs/tower#682

@seanmonstar seanmonstar removed the C-feature Category: feature. This is adding a new feature. label Aug 12, 2022
@seanmonstar seanmonstar closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2022
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

2 participants