diff options
author | guochuyicmri <guochuyi@chinamobile.com> | 2019-05-15 06:10:14 +0800 |
---|---|---|
committer | guochuyicmri <guochuyi@chinamobile.com> | 2019-05-15 06:10:17 +0800 |
commit | 47792b037c6bcbcb4fe5a9429af9e4fb538d2ad4 (patch) | |
tree | af672a9566726e4d5239c9694aab59fadd17bddd | |
parent | ec80acfa637375ad1337e972eba16be04a4bc67c (diff) |
Fix NS parser calling timeout bug
Change-Id: I2a74fd83c3c4bd287b73339d8268ad8726873317
Issue-ID: USECASEUI-267
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
-rw-r--r-- | server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java b/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java index 450e362b..1b3a5ec1 100644 --- a/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java +++ b/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java @@ -18,6 +18,7 @@ package org.onap.usecaseui.server.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.util.concurrent.TimeUnit; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; @@ -28,6 +29,7 @@ import org.slf4j.LoggerFactory; import com.alibaba.dubbo.common.utils.IOUtils; import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.RequestBody; import retrofit2.Retrofit; import retrofit2.converter.jackson.JacksonConverterFactory; @@ -45,9 +47,15 @@ public class RestfulServices { } public static <T> T create(Class<T> clazz) { + //Set the interface response time + final OkHttpClient client = new OkHttpClient.Builder(). + connectTimeout(300, TimeUnit.SECONDS). + readTimeout(300, TimeUnit.SECONDS). + writeTimeout(300, TimeUnit.SECONDS).build(); String msbUrl = getMsbAddress(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://" + msbUrl+"/") + .baseUrl("http://" + msbUrl + "/") + .client(client) .addConverterFactory(JacksonConverterFactory.create()) .build(); return retrofit.create(clazz); |