Skip to content

Commit

Permalink
update check service: set a lower connect timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Apr 23, 2018
1 parent f8d9f0e commit 02fd016
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
Expand All @@ -52,6 +54,8 @@ public class UpdateCheckService
{
private static final Logger logger = LoggerFactory.getLogger(UpdateCheckService.class);

private static final Duration TIMEOUT = Duration.ofSeconds(5);

private static final int PORT = 43594;
private static final byte HANDSHAKE_TYPE = 15;

Expand Down Expand Up @@ -93,8 +97,10 @@ private boolean checkUpdate()
return false;
}

try (Socket socket = new Socket(address, PORT))
try (Socket socket = new Socket())
{
socket.connect(new InetSocketAddress(address, PORT), (int) TIMEOUT.toMillis());

ByteBuffer buffer = ByteBuffer.allocate(5);
buffer.put(HANDSHAKE_TYPE);
buffer.putInt(RuneLiteAPI.getRsVersion());
Expand Down

0 comments on commit 02fd016

Please sign in to comment.