Skip to content

Commit

Permalink
Add long read timeout okHttpClient for clan rank updates
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Thornton <44626690+thorntonmatthewd@users.noreply.github.com>
  • Loading branch information
Cyborger1 and ThorntonMatthewD committed Jun 9, 2021
1 parent 32f701b commit 18f3986
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/com/botdetector/http/BotDetectorClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,22 @@ private enum ApiPath
final String path;
}

/**
* {@link RuneLiteAPI#CLIENT} with a connect/read timeout of 30 seconds each and no pinging.
*/
public static OkHttpClient okHttpClient = RuneLiteAPI.CLIENT.newBuilder()
.pingInterval(0, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();

/**
* Same as {@link #okHttpClient}, but with a read timeout of 60 seconds.
*/
public static OkHttpClient longTimeoutHttpClient = okHttpClient.newBuilder()
.readTimeout(60, TimeUnit.SECONDS)
.build();

@Inject
private GsonBuilder gsonBuilder;

Expand Down Expand Up @@ -445,7 +455,7 @@ public CompletableFuture<Map<CaseInsensitiveString, ClanRank>> requestClanRankUp
.build();

CompletableFuture<Map<CaseInsensitiveString, ClanRank>> future = new CompletableFuture<>();
okHttpClient.newCall(request).enqueue(new Callback()
longTimeoutHttpClient.newCall(request).enqueue(new Callback()
{
@Override
public void onFailure(Call call, IOException e)
Expand Down

0 comments on commit 18f3986

Please sign in to comment.