Skip to content

Commit ea37aa7

Browse files
committed
Another attempt to fix the bot timing out...
Signed-off-by: KiriCattus <19393068+KiriCattus@users.noreply.github.com>
1 parent 0e5a921 commit ea37aa7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/commander/java/com/mcmoddev/mmdbot/commander/updatenotifiers/SharedVersionHelpers.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
import java.time.Duration;
4141

4242
public class SharedVersionHelpers {
43-
43+
private static final HttpClient client = HttpClient.newBuilder()
44+
.connectTimeout(Duration.ofSeconds(10L))
45+
.followRedirects(HttpClient.Redirect.NORMAL)
46+
.build();
4447

4548
public static InputStreamReader getReader(final String urlString) {
4649
final InputStream stream = getStream(urlString);
@@ -54,12 +57,10 @@ public static InputStreamReader getReader(final String urlString) {
5457
@Nullable
5558
public static InputStream getStream(final String urlString) {
5659
try {
57-
HttpClient client = HttpClient.newBuilder()
58-
.connectTimeout(Duration.ofSeconds(5L))
59-
.followRedirects(HttpClient.Redirect.NORMAL)
60-
.build();
6160
HttpRequest request = HttpRequest.newBuilder()
6261
.uri(URI.create(urlString))
62+
.header("User-Agent", "MMDBot")
63+
.timeout(Duration.ofSeconds(30L))
6364
.build();
6465

6566
HttpResponse<InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

0 commit comments

Comments
 (0)