Reputation: 1
I’m facing an issue where the OkHttp client timeout doesn't work as expected.
Conditions:
About the Program:
Flow:
myapp-->nlb-->ingress-->API
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);
Upvotes: 0
Views: 42