Webclient SslHandshakeTimeoutException:10000ms 后握手超时

问题描述 投票:0回答:1

我最近使用 webflux 和 webclient 制作了一个组件。 有一些请求使用外部资源来检索某些数据。 在本地工作一切正常,从外部资源检索数据并正确显示给用户。 当我在远程服务器上进行部署时,它不再工作,并且显示以下错误:


i.n.r.DefaultHostsFileEntriesResolver    : -Dio.netty.hostsFileRefreshInterval: 0
Jan 08 23:59:31 dlv-izac-user app/web.1 2023-01-09 07:59:30.715 DEBUG 4 --- [or-http-epoll-7] i.n.util.ResourceLeakDetectorFactory     : Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@5abf28c7
Jan 08 23:59:31 dlv-izac-user app/web.1 2023-01-09 07:59:30.717 DEBUG 4 --- [or-http-epoll-7] io.netty.resolver.dns.DnsQueryContext    : [id: 0x477cca20] WRITE: UDP, [45834: /10.1.0.2:53], DefaultDnsQuestion(izac-dlv.herokuapp.com. IN A)
Jan 08 23:59:31 dlv-izac-user app/web.1 2023-01-09 07:59:30.722  WARN 4 --- [or-http-epoll-7] io.netty.channel.epoll.EpollEventLoop    : Unexpected exception in the selector loop.
Jan 08 23:59:31 dlv-izac-user app/web.1 io.netty.channel.unix.Errors$NativeIoException: epoll_wait(..) failed: Function not implemented
Jan 08 23:59:32 dlv-izac-user app/web.1 2023-01-09 07:59:31.722  WARN 4 --- [or-http-epoll-7] io.netty.channel.epoll.EpollEventLoop    : Unexpected exception in the selector loop.
Jan 08 23:59:32 dlv-izac-user app/web.1 io.netty.channel.unix.Errors$NativeIoException: epoll_wait(..) failed: Function not implemented
Jan 08 23:59:33 dlv-izac-user app/web.1 2023-01-09 07:59:32.723  WARN 4 --- [or-http-epoll-7] io.netty.channel.epoll.EpollEventLoop    : Unexpected exception in the selector loop.
Jan 08 23:59:33 dlv-izac-user app/web.1 io.netty.channel.unix.Errors$NativeIoException: epoll_wait(..) failed: Function not implemented
Jan 08 23:59:34 dlv-izac-user app/web.1 2023-01-09 07:59:33.723  WARN 4 --- [or-http-epoll-7] io.netty.channel.epoll.EpollEventLoop    : Unexpected exception in the selector loop.
Jan 08 23:59:34 dlv-izac-user app/web.1 io.netty.channel.unix.Errors$NativeIoException: epoll_wait(..) failed: Function not implemented
Jan 08 23:59:35 dlv-izac-user app/web.1 2023-01-09 07:59:34.724  WARN 4 --- [or-http-epoll-7] io.netty.channel.epoll.EpollEventLoop    : Unexpected exception in the selector loop.
Jan 08 23:59:35 dlv-izac-user app/web.1 io.netty.channel.unix.Errors$NativeIoException: epoll_wait(..) failed: Function not implemented
Jan 08 23:59:36 dlv-izac-user app/web.1 2023-01-09 07:59:35.734 DEBUG 4 --- [or-http-epoll-7] io.netty.resolver.dns.DnsNameResolver    : [id: 0x477cca20] RECEIVED: UDP [45834: /10.1.0.2:53], DatagramDnsResponse(from: /10.1.0.2:53, 45834, QUERY(0), NoError(0), RD RA)
Jan 08 23:59:36 dlv-izac-user app/web.1     DefaultDnsQuestion(izac-dlv.herokuapp.com. IN A)
Jan 08 23:59:36 dlv-izac-user app/web.1     DefaultDnsRawRecord(izac-dlv.herokuapp.com. 9 IN A 4B)
Jan 08 23:59:36 dlv-izac-user app/web.1     DefaultDnsRawRecord(izac-dlv.herokuapp.com. 9 IN A 4B)
Jan 08 23:59:36 dlv-izac-user app/web.1     DefaultDnsRawRecord(izac-dlv.herokuapp.com. 9 IN A 4B)
Jan 08 23:59:36 dlv-izac-user app/web.1     DefaultDnsRawRecord(OPT flags:0 udp:4096 0B)

Jan 09 00:00:16 dlv-izac-user app/web.1 2023-01-09 08:00:15.814  WARN 4 --- [or-http-epoll-8] r.netty.http.client.HttpClientConnect    : [fc253c96, L:/172.19.105.50:34258 - R:izac-dlv.herokuapp.com/46.137.15.86:443] The connection observed an error
Jan 09 00:00:16 dlv-izac-user app/web.1 io.netty.handler.ssl.SslHandshakeTimeoutException: handshake timed out after 10000ms
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.handler.ssl.SslHandler$7.run(SslHandler.java:2113) ~[netty-handler-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:170) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:391) ~[netty-transport-classes-epoll-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.76.Final.jar!/:4.1.76.Final]
Jan 09 00:00:16 dlv-izac-user app/web.1     at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]

这是我使用 webClient 进行的通话

  URI uri = UriComponentsBuilder.fromHttpUrl(izacComponentUrl)
                .queryParam("request", request)
                .build().toUri();

            WebClient client = WebClient.builder()
                .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                .build();

        return  client.get()
                .uri(uri)
                .retrieve()
                .bodyToFlux(RestaurantInfoResponseBody.class)
                .onErrorContinue(RuntimeException.class, (ex, o) -> log.error("Errore durante il recupero dei dati tramite il servizio esterno!"));
    }
spring-boot heroku deployment spring-webflux webclient
1个回答
0
投票

您使用任何 SslProvider 吗?

因为一般来说,该错误发生在 SSL 握手期间。 您可以在 SslProvider 构建器中设置一个参数来增加超时时间,如下所示:

SSL Context sslContext = SslContextBuilder
    .forClient()
    .trustManager(InsecureTrustManagerFactory.INSTANCE) //disable https
    .build();

SslProvider sslProvider = SslProvider
    .builder()
    .sslContext(sslContext)
    .handshakeTimeoutMillis(20000) //higher timeout
    .build();
© www.soinside.com 2019 - 2024. All rights reserved.