From aef54e640f35d1936b469faab95537775d978fc5 Mon Sep 17 00:00:00 2001 From: Kathurima <41376826+KathurimaKimathi@users.noreply.github.com> Date: Wed, 30 Aug 2023 14:27:36 +0300 Subject: [PATCH] fix: increase patient sync request timeout (#107) - gives kenya emr room to synchronize mycarehub backend server Signed-off-by: Kathurima Kimathi --- .../openmrs/module/mycarehub/api/rest/ApiClient.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/mycarehub/api/rest/ApiClient.java b/api/src/main/java/org/openmrs/module/mycarehub/api/rest/ApiClient.java index 242e95e..e764014 100644 --- a/api/src/main/java/org/openmrs/module/mycarehub/api/rest/ApiClient.java +++ b/api/src/main/java/org/openmrs/module/mycarehub/api/rest/ApiClient.java @@ -3,6 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import org.apache.commons.logging.Log; @@ -20,6 +21,8 @@ public class ApiClient { private static Retrofit retrofit = null; + private static final long timeoutDuration = 2; + public static RestApiService getRestService() { if (retrofit == null) { Gson gson = @@ -30,7 +33,12 @@ public static RestApiService getRestService() { HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); - OkHttpClient client = new OkHttpClient.Builder().addInterceptor(loggingInterceptor).build(); + OkHttpClient client = + new OkHttpClient.Builder() + .addInterceptor(loggingInterceptor) + .connectTimeout(timeoutDuration, TimeUnit.MINUTES) + .readTimeout(timeoutDuration, TimeUnit.MINUTES) + .build(); retrofit = new Retrofit.Builder() .baseUrl(apiUrl)