'okhttp3 client - spring boot application - 500 Internal error while calling API endpoint
We are calling a third-party-https API endpoint over the internet using okhttp3 client from our application. APM tool (Datadog) history shows 500 error for all our API requests on the day third-party API owner made some internal changes behind the Domain name (We still call API by domain not by IP). We were getting 500 error till we did a application restart.
Our application is scaled enough to manage high TPS.
okhhtp3 version: 3.14.9 Spring Boot version: 2.3.3
What could be the reason for 500 error from client perspective? What could be the solution to avoid this in future?
okhttp3 - Client code block
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
okHttpClientBuilder.retryOnConnectionFailure(true);
okHttpClientBuilder.connectTimeout(environmentConfig.getConnectionTimeOut(), TimeUnit.MILLISECONDS);
okHttpClientBuilder.readTimeout(environmentConfig.getReadTimeOut(), TimeUnit.MILLISECONDS);
okHttpClientBuilder.writeTimeout(environmentConfig.getWriteTimeout(), TimeUnit.MILLISECONDS);
okHttpClientBuilder.addInterceptor(getOKHttpInterceptorLog());
okHttpClientBuilder.connectionPool(new ConnectionPool(512, 60000, TimeUnit.MILLISECONDS));
okHttpClientBuilder.addInterceptor(new OkHttpInterceptor());
return okHttpClientBuilder.build();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
