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-issuemaster opened this issue Dec 25, 2018 · 2 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 2, 2019

ailin zhou commented

Ok, got it, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.