admin管理员组文章数量:1410674
I’m facing an issue where the OkHttp client timeout doesn't work as expected.
Conditions:
About the Program:
- java client (Feign) generated using OpenAPI Generator.
- Using OkHttp 3 client.
Flow:
myapp-->nlb-->ingress-->API
- When the NLB (Network Load Balancer) stops, the client responds immediately (in this case, the timeout is irrelevant).
- If the NLB is functioning properly and ingress is stopped, for some reason, no response is returned. Additionally, the configured timeout does not work, and the client waits for more than one hour.
The issue: When NLB does not return a response, my app keeps waiting for a response, ignoring the timeout configuration.
Questions: What could be causing this behavior? How can I ensure that the timeout is respected when NLB fails to respond?
The timeout was shortened as shown below in the configuration, and retries were also disabled. However, this does not resolve the issue. The client continues to wait beyond the specified timeout period, and no timeout error occurs.
The code I am using is as follows:
Builder builder = apiClient.getFeignBuilder();
// Options options = new Options(10L, TimeUnit.SECONDS, 14L, TimeUnit.MINUTES, true);
// builder.options(options);
OkHttpClient client = new OkHttpClient.Builder()
.callTimeout(10, TimeUnit.SECONDS)
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.writeTimeout(5, TimeUnit.SECONDS)
.retryOnConnectionFailure(false)
.build();
Client client1 = new feign.okhttp.OkHttpClient(client);
builder.client(client1);
apiClient.setFeignBuilder(builder);
本文标签: javaOkHttp client timeout does not work when using NLB (Network Load Balancer)Stack Overflow
版权声明:本文标题:java - OkHttp client timeout does not work when using NLB (Network Load Balancer) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744939649a2633405.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论