Proxy/Netty: connection timed out

I’m having an issue setting up the proxy in the server using Java Spring.



I’m setting up correctly the System Properties (super duper checked): https.proxyHost and https.proxyPort (both http and https by the way).

I’m still getting the following error:

    ERROR  o.s.b.a.w.r.e.AbstractErrorWebExceptionHandler - [b56689f3-47]  500 Server Error for HTTP GET "/login/oauth2/code/okta?code=KBQg4hasKPrhK4XIQ-C_&state=t00sJi7U2v5vYeMRQmYX6Qb9Gn8pGdzhfxHfI1yXVx8%3D" connection timed out:
    	at$AbstractEpollUnsafe$ ~[netty-transport-native-epoll-4.1.49.Final-linux-x86_64.jar!/:4.1.49.Final]
    	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
    Error has been observed at the following site(s):
    	|_ checkpoint ⇢ Request to POST [DefaultWebClient]
    	|_ checkpoint ⇢ [DefaultWebFilterChain]
    	|_ checkpoint ⇢ [DefaultWebFilterChain]
    	|_ checkpoint ⇢ [DefaultWebFilterChain]
    	|_ checkpoint ⇢ [DefaultWebFilterChain]
    	|_ checkpoint ⇢$ServerWebExchangeReactorContextWebFilter [DefaultWebFilterChain]
    	|_ checkpoint ⇢ [DefaultWebFilterChain]
    	|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
    	|_ checkpoint ⇢ HTTP GET "/login/oauth2/code/okta?code=KBQg4hasKPrhK4XIQ-C_&state=t00sJi7U2v5vYeMRQmYX6Qb9Gn8pGdzhfxHfI1yXVx8%3D" [ExceptionHandlingWebHandler]
    Stack trace:
    		at$AbstractEpollUnsafe$ ~[netty-transport-native-epoll-4.1.49.Final-linux-x86_64.jar!/:4.1.49.Final]
    		at io.netty.util.concurrent.PromiseTask.runTask( ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at io.netty.util.concurrent.AbstractEventExecutor.safeExecute( ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks( ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at ~[netty-transport-native-epoll-4.1.49.Final-linux-x86_64.jar!/:4.1.49.Final]
    		at io.netty.util.concurrent.SingleThreadEventExecutor$ ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at io.netty.util.internal.ThreadExecutorMap$ ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at ~[netty-common-4.1.49.Final.jar!/:4.1.49.Final]
    		at java.base/ ~[na:na]

I’m able to reach the end-point via curl using the proxy setting (receive an error message successfully):

    curl -x proxy:8080 -d 'testing connection'
    {"errorCode":"invalid_client","errorSummary":"Invalid value for 'client_id' parameter.","errorLink":"invalid_client","errorId":"oae-Ovwyzv5RRORF1AaskoC4Q","errorCauses":[]}[

I would appreciate any help on this. Already spent a considerable amount of time trying different things.

are you able to see those system properties inside your application? have you tried to dump them into the log? to me it’s netty failing, based on the exception stack trace attached

This seems to be a common known problem:

Can OKTA provide an example on how to work around this issue?

Sorry for the delay on this one.

It looks like this is a known issue for Spring Security:

I have a couple of suggestions:

  1. Remove the need for a proxy, you could whitelist the domains you need (or specific URLs if needed)
    I know this isn’t always possible, especially when someone else manages the network, but it’s easiest option, so I figured I’d suggest it

  2. Override the WebClient where it’s used.

You could BeanPostProcessor it, and tweak the WebClient

same for

If you are also validating JWTs you would need to replace the ReactiveJwtDecoder bean from:

With something like:


Where your custom webClient is something like:

HttpClient httpClient = HttpClient.create()
            .tcpConfiguration(tcpClient -> tcpClient
                .proxy(proxy -> proxy
1 Like