javalin
javalin copied to clipboard
http2 SSL websocket on linux never calls onconnect
We use Javalin from a Java application on Linux. The code was created following the official Javalin docs. The code that configures the http, SSL, and websocket looks like
Java 21
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin</artifactId>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>io.javalin.community.ssl</groupId>
<artifactId>ssl-plugin</artifactId>
<version>6.6.0</version>
</dependency>
Javalin app = Javalin.create(cfg -> {
cfg.showJavalinBanner = false;
cfg.staticFiles.add("/public", Location.CLASSPATH);
cfg.jsonMapper(new JavalinJackson().updateMapper(mapper -> {
mapper.setFilterProvider(new SimpleFilterProvider()
.addFilter("filterArgs", SimpleBeanPropertyFilter.serializeAll())
.setFailOnUnknownId(false));
}));
// configure HTTPS
if (config.isSslEnabled()) {
SslPlugin sslPlugin = new SslPlugin(cc -> {
cc.keystoreFromPath(config.getKeystoreFile(), config.getKeystorePassword());
cc.securePort = config.getPort();
cc.host = "0.0.0.0"; // default is 'localhost'
});
cfg.registerPlugin(sslPlugin);
}
// configure websockets
cfg.router.mount(router -> {
...
getRequestWSHandler(router);
...
});
});
private void getRequestWSHandler(JavalinDefaultRouting router) {
router.ws("/request", ws -> {
ws.onConnect(ctx -> {
...
});
ws.onClose(ctx -> {
..
});
ws.onMessage(ctx -> {
...
});
});
}
Note that the HTTP SSL connection works Fine. We also wrote a small test app directly using jetty websocket, and it works fine too.
The Javalin websocket however is Not Working at all. The breakpoint on ws.onConnect(...) above is never called, and no related errors is generated either.
Having a hard time even figuring out where to set the breakpoints to debug this.
@mahresohl does it only happen on Linux?
Could you create a PR with a failing test?