commit 613f55e332e707e3b208758ff5d454555b77fd3f
parent ef3a2d065d074c5e7f4a8337e0fb0e5741d2b0d1
Author: Wim Dupont <wim@wimdupont.com>
Date: Fri, 8 Jul 2022 20:32:08 +0200
increased client read timeouts
Diffstat:
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/sxcy/sxcybot/client/GrandExchangeClient.java b/src/main/java/com/sxcy/sxcybot/client/GrandExchangeClient.java
@@ -1,15 +1,16 @@
package com.sxcy.sxcybot.client;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.sxcy.sxcybot.exceptions.EntityNotFoundException;
import com.sxcy.sxcybot.model.OsrsItem;
import com.sxcy.sxcybot.util.NumberFormatter;
-import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import net.dv8tion.jda.api.entities.MessageChannel;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
+import java.time.Duration;
import java.util.Map;
@Component
@@ -23,6 +24,7 @@ public class GrandExchangeClient {
public String getPrice(String itemName, MessageChannel channel) throws EntityNotFoundException {
RestTemplate restTemplate = new RestTemplateBuilder()
.errorHandler(new ClientErrorHandler(channel))
+ .setReadTimeout(Duration.ofSeconds(30))
.build();
Object result = restTemplate.getForEntity(String.format(URL, itemName), Object.class).getBody();
if (result != null) {
diff --git a/src/main/java/com/sxcy/sxcybot/client/HiScoreClient.java b/src/main/java/com/sxcy/sxcybot/client/HiScoreClient.java
@@ -17,6 +17,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -65,6 +66,7 @@ public class HiScoreClient {
List<T> hiScoreList = new ArrayList<>();
RestTemplate restTemplate = new RestTemplateBuilder()
.errorHandler(new ClientErrorHandler(channel))
+ .setReadTimeout(Duration.ofSeconds(30))
.build();
String result = restTemplate.getForObject(String.format(URL, playername), String.class);
if (result != null) {