Compare commits

..

2 commits

Author SHA1 Message Date
01738a5f0a discord-ws: Fix to reconnect on 1000-1006 error codes
All checks were successful
ci/woodpecker/push/java Pipeline was successful
ci/woodpecker/push/oci-image-build Pipeline was successful
ci/woodpecker/manual/java Pipeline was successful
ci/woodpecker/manual/oci-image-build Pipeline was successful
2024-12-04 23:14:03 +01:00
5c16c60782 misc: Cleanup 2024-12-04 20:32:46 +01:00
5 changed files with 4 additions and 8 deletions

View file

@ -1,7 +1,7 @@
package de.hhhammer.dchat.discord.ws;
public interface Retryer {
public int nextRetryInSeconds();
int nextRetryInSeconds();
public boolean hasRetriesLeft();
boolean hasRetriesLeft();
}

View file

@ -4,9 +4,7 @@ import de.hhhammer.dchat.discord.ws.Retryer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Duration;
import java.time.LocalTime;
import java.util.Timer;
import java.util.concurrent.atomic.AtomicInteger;
public final class BackoffRetryer implements Retryer {

View file

@ -1,7 +1,6 @@
package de.hhhammer.dchat.discord.ws.connection;
import de.hhhammer.dchat.discord.ws.Retryer;
import de.hhhammer.dchat.discord.ws.connection.event.CloseEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -14,7 +14,6 @@ import java.net.http.WebSocket;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@ -117,7 +116,8 @@ public final class DiscordListener implements WebSocket.Listener {
case 4000, 4001, 4002, 4005, 4008 ->
this.closeEventQueue.add(new CloseEvent.ResumableCloseEvent(this.resumeGatewayUrl.get(), this.sessionId.get(), lastSeq.get()));
// 1000 and 1001 can be sent or received as close code and should trigger reconnect -> https://discord.com/developers/docs/events/gateway#initiating-a-disconnect
case 0, 4003, 4007, 4009 -> this.closeEventQueue.add(new CloseEvent.UnresumableCloseEvent());
// 1006 unexpected error and comes without description - reconnect seems fine ->
case 1000, 1001, 1006, 4003, 4007, 4009 -> this.closeEventQueue.add(new CloseEvent.UnresumableCloseEvent());
case 4004, 4010, 4011, 4012, 4013, 4014 ->
this.closeEventQueue.add(new CloseEvent.UnrecoverableCloseEvent());
default -> {

View file

@ -9,7 +9,6 @@
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>de.hhhammer.dchat</groupId>
<artifactId>openai-rest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>