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

RestTemplate can't set timeout pre request [SPR-17624] #22156

Closed
spring-projects-issues opened this issue Dec 25, 2018 · 2 comments
Closed

RestTemplate can't set timeout pre request [SPR-17624] #22156

spring-projects-issues opened this issue Dec 25, 2018 · 2 comments
Assignees
Labels
in: web status: declined type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Dec 25, 2018

ailin zhou opened SPR-17624 and commented

Use RestTemplate send request to difference url, we want different request have different SocketTimeout parameter. 

Currently RestTemplate doesn't have any interface costum timeout for pre request. 

The HttpComponentsClientHttpRequestFactory can custum RequestConfig but when use with RestTemplate we have no chance to set timeout parameter.


No further details from SPR-17624

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 27, 2018

Brian Clozel commented

RestTemplate is a wrapper around HTTP clients that provides a unified API. Many HTTP client libraries are supported, including the JDK client, Apache HTTP components, okhttp, and others.

Configuring a per-request timeout is not something that's consistently supported in all clients and we tend to leave it to the native library. In this case, I believe you can use a specific configuration on Apache Http components to set that timeout on a per-host basis but you're right, RestTemplate does not offer that feature.

I don't see any way to support this feature for all supported clients.

As a workaround, you can either use the underlying library directly or switch to WebClient which provides a timeour operator natively on Mono.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 2, 2019

ailin zhou commented

Ok, got it, thank you.

@spring-projects-issues spring-projects-issues added status: declined type: enhancement in: web labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web status: declined type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants