Describe the bug We are using OAUth Client to generate OAuth token using client credentials auth method. While first call to generate token succeeds, calls after some time essentially fail with following error:

2022-03-29 03:42:45.785 WARN 1 --- [or-http-epoll-3] r.n.h.c.HttpClientConnect : [2ecec8c1-2, L:/10.1.203.152:40838 - R:apim.workato.com/34.228.98.142:443] The connection observed an error, the request cannot be retried as the headers/body were sent

io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

What's happening is connection opened from WebClient idles out and server side eventually closes it running into this issue. We traced it to this use of default WebClient in AbstractWebClientReactiveOAuth2AccessTokenResponseClient which is not configured to use any idle time. Is there a way to set instance of WebClient to AbstractWebClientReactiveOAuth2AccessTokenResponseClient so that we can configure things like idle timeout on it.

To Reproduce Steps to reproduce the behavior. 1. Configure OAuth client, generate token 2. Wait for time more than OAuth server's idle timeout 3. Make another call to generate token, it'll fail

Expected behavior With us being able to inject WebClient, we'll be able to control idle timeout and discard any connection that's lying idle for time less than server's specified idle timeout.

Sample

A link to a GitHub repository with a minimal, reproducible sample.

Reports that include a sample will take priority over reports that do not. At times, we may require a sample, so it is good to try and include a sample up front.

Comment From: sjohnr

Hi @sidgod welcome to the project!

The AbstractWebClientReactiveOAuth2AccessTokenResponseClient class (and all inheritors) have a setWebClient() method for just that purpose! Take a look at our recently updated reference docs on ReactiveOAuth2AuthorizedClientProvider.

You will be most interested in the following section on Customizing the WebClient.

Since this is well documented in the reference documentation, I'm going to close this issue for now. If you feel stuck, feel free to open a question on Stack Overflow and update this issue with a link to the re-posted question (so that other people can find it), and I'll be happy to take a look!