added connection timeout and socket timeout 600 sec

This commit is contained in:
Miriam Baglioni 2020-10-27 15:53:02 +01:00
parent 346ed65e2c
commit 1cb60aede4
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package eu.dnetlib.dhp.common.api;
import java.io.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import com.google.gson.Gson;
@ -92,7 +93,11 @@ public class ZenodoAPIClient implements Serializable {
* @return the response code
*/
public int uploadIS(InputStream is, String file_name, long len) throws IOException {
OkHttpClient httpClient = new OkHttpClient();
OkHttpClient httpClient = new OkHttpClient
.Builder()
.connectTimeout(600, TimeUnit.SECONDS)
.readTimeout(600, TimeUnit.SECONDS)
.writeTimeout(600, TimeUnit.SECONDS).build();
Request request = new Request.Builder()
.url(bucket + "/" + file_name)