Fixed too short idle timeout for Jetty's WebSocket
This commit is contained in:
@@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.WebSocket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
@@ -38,6 +38,17 @@
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.0.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.4.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -3,16 +3,17 @@ package io.github.lumijiez;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.websocket.WsContext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public class JavalinConfig {
|
||||
private static final Map<String, WsContext> users = new ConcurrentHashMap<>();
|
||||
private static final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
public static void setup(Javalin app) {
|
||||
app.get("/check", ctx -> ctx.result("OK"));
|
||||
|
||||
app.ws("/discovery", ws -> {
|
||||
public static void setup(Javalin app) { app.ws("/discovery", ws -> {
|
||||
ws.onConnect(ctx -> {
|
||||
String id = ctx.sessionId();
|
||||
users.put(id, ctx);
|
||||
|
||||
@@ -3,9 +3,16 @@ package io.github.lumijiez;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.json.JavalinGson;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Javalin app = Javalin.create(config -> config.jsonMapper(new JavalinGson())).start(8083);
|
||||
Javalin app = Javalin.create(config -> {
|
||||
config.jsonMapper(new JavalinGson());
|
||||
config.jetty.modifyWebSocketServletFactory(wsFactoryConfig -> {
|
||||
wsFactoryConfig.setIdleTimeout(Duration.ZERO);
|
||||
});
|
||||
}).start(8083);
|
||||
|
||||
JavalinConfig.setup(app);
|
||||
|
||||
|
||||
@@ -107,7 +107,6 @@ services:
|
||||
- POSTGRES_USER=symphony
|
||||
- POSTGRES_PASSWORD=symphony
|
||||
- POSTGRES_DB=symphony
|
||||
- POSTGRES_INITDB_ARGS="--log-min-messages=error"
|
||||
volumes:
|
||||
- ./config/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
ports:
|
||||
|
||||
Reference in New Issue
Block a user