Skip to content

Commit

Permalink
7.2.20
Browse files Browse the repository at this point in the history
Possible fix for "Read timed out" when opening any connection and AP-Web is overloaded
  • Loading branch information
Osiris-Team committed May 11, 2023
1 parent 6f87def commit 386dd3b
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public synchronized void setAndStartAsync(RunnableWithException runnable) {
this.thread = new Thread(() -> {
try {
runnable.run();
} catch (Exception e) {
if (!isClosing.get()) AL.warn(e); // Exceptions caused by close() are ignored
} catch (Exception e) { // Exceptions caused by close() are ignored
if (!isClosing.get()) AL.warn(e);
try {
_close(Thread.currentThread(), _in, _out, _socket);
} catch (Exception ex) {
Expand All @@ -110,6 +110,7 @@ public synchronized boolean open() throws Exception {
}

private synchronized int _open() throws Exception {
socket.setSoTimeout(60000);
isClosing.set(false);
errorCode = 0;
close();
Expand Down Expand Up @@ -143,12 +144,8 @@ private synchronized int _open() throws Exception {
}

AL.debug(this.getClass(), "[CON_TYPE: " + conType + "] Authenticating server with Server-Key...");
socket.setSoTimeout(30000);
out.writeUTF(serverKey); // Send server key
out.writeByte(conType); // Send connection type
socket.setSoTimeout(5000);


this.errorCode = in.readByte(); // Get response
return errorCode;
}
Expand Down Expand Up @@ -285,7 +282,7 @@ private void _close(Thread thread, InputStream in, OutputStream out, Socket sock
if (in != null) in.close();
if (out != null) out.close();
if (socket != null) socket.close();
if (thread != null) thread.interrupt();
if (thread != null) thread.interrupt(); // Close thread last, since it might be the current thread
}

@Override
Expand Down

0 comments on commit 386dd3b

Please sign in to comment.