Skip to content

Commit c3ddb59

Browse files
committed
Better http client configuration
1 parent 30661d7 commit c3ddb59

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The second thing we have to do is add the spawn dependency to the project.
9090
<dependency>
9191
<groupId>com.github.eigr</groupId>
9292
<artifactId>spawn-java-std-sdk</artifactId>
93-
<version>v0.3.5</version>
93+
<version>v0.4.1</version>
9494
</dependency>
9595
```
9696
We're also going to configure a few things for our application build to work, including compiling the protobuf files.
@@ -124,7 +124,7 @@ See below a full example of the pom.xml file:
124124
<dependency>
125125
<groupId>com.github.eigr</groupId>
126126
<artifactId>spawn-java-std-sdk</artifactId>
127-
<version>v0.3.5</version>
127+
<version>v0.4.1</version>
128128
</dependency>
129129
<dependency>
130130
<groupId>ch.qos.logback</groupId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>io.eigr.spawn</groupId>
55
<artifactId>spawn-java-std-sdk</artifactId>
66
<packaging>jar</packaging>
7-
<version>0.3.5</version>
7+
<version>0.4.1</version>
88
<name>spawn-java-std-sdk</name>
99
<url>http://maven.apache.org</url>
1010

src/main/java/io/eigr/spawn/internal/client/OkHttpSpawnClient.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.slf4j.LoggerFactory;
77

88
import java.util.Objects;
9+
import java.util.concurrent.TimeUnit;
910

1011
public final class OkHttpSpawnClient implements SpawnClient {
1112
private static final Logger log = LoggerFactory.getLogger(OkHttpSpawnClient.class);
@@ -20,13 +21,18 @@ public final class OkHttpSpawnClient implements SpawnClient {
2021
private final int proxyPort;
2122
private final OkHttpClient client;
2223

23-
//private SpawnProperties properties;
24-
2524
public OkHttpSpawnClient(String system, String proxyHost, int proxyPort) {
2625
this.system = system;
2726
this.proxyHost = proxyHost;
2827
this.proxyPort = proxyPort;
29-
this.client = new OkHttpClient();
28+
this.client = new OkHttpClient.Builder()
29+
.connectTimeout(30, TimeUnit.SECONDS)
30+
.readTimeout(30, TimeUnit.SECONDS)
31+
.writeTimeout(30, TimeUnit.SECONDS)
32+
.callTimeout(100, TimeUnit.SECONDS)
33+
.retryOnConnectionFailure(true)
34+
.connectionPool(new ConnectionPool(256, 100, TimeUnit.SECONDS))
35+
.build();
3036
}
3137

3238
@Override

0 commit comments

Comments
 (0)