Skip to content

Commit b2a7317

Browse files
committed
possible timeout fix for filemanager
1 parent 820cfca commit b2a7317

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/java/com/osiris/autoplug/client/console/Commands.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,17 @@ public static boolean execute(@NotNull String command) {
168168
AL.info(Main.CON.CON_PRIVATE_DETAILS.toString());
169169
AL.info(Main.CON.CON_CONSOLE_SEND.toString());
170170
AL.info(Main.CON.CON_CONSOLE_RECEIVE.toString());
171+
AL.info(Main.CON.CON_SYSTEM_CONSOLE_SEND.toString());
172+
AL.info(Main.CON.CON_SYSTEM_CONSOLE_RECEIVE.toString());
171173
AL.info(Main.CON.CON_FILE_MANAGER.toString());
172174
return true;
173175
} else if (command.equals(".con reload") || command.equals(".cr")) {
176+
if(Main.CON.reconnectThread != null){
177+
try{
178+
Main.CON.reconnectThread.interrupt();
179+
} catch (Exception e) {}
180+
AL.debug(Commands.class, "Stopped reconnect thread.");
181+
}
174182
Main.CON.close();
175183
AL.info("Closed connections, reconnecting in 10 seconds...");
176184
Thread.sleep(10000);

src/main/java/com/osiris/autoplug/client/network/online/ConMain.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.netty.channel.ChannelHandlerContext;
77
import io.netty.handler.codec.ReplayingDecoder;
88
import io.netty.handler.timeout.IdleStateHandler;
9+
import org.jetbrains.annotations.Nullable;
910

1011
import java.security.InvalidKeyException;
1112
import java.util.List;
@@ -100,9 +101,12 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
100101
return true;
101102
}
102103

104+
public @Nullable Thread reconnectThread = null;
105+
103106
private void scheduleReconnect() {
104107
if (isClosing.get()) return;
105-
new Thread(() -> {
108+
if(reconnectThread != null) try{reconnectThread.interrupt();} catch (Exception e) {}
109+
reconnectThread = new Thread(() -> {
106110
try {
107111
AL.warn("Connection problems! Reconnecting in " + msUntilRetry / 1000 + " seconds...");
108112
Thread.sleep(msUntilRetry);
@@ -111,7 +115,8 @@ private void scheduleReconnect() {
111115
} catch (Exception e) {
112116
AL.warn("Reconnect error", e);
113117
}
114-
}).start();
118+
});
119+
reconnectThread.start();
115120
close();
116121
}
117122

0 commit comments

Comments
 (0)