Skip to content

Websockets are broken #3814

@ogrammer

Description

@ogrammer

I am using jooby 4.0.11 with jetty, and websockets are really broken.

My client is using https://github.com/TooTallNate/Java-WebSocket and I can clearly see in wireshark that the messages are sent, but I don't receive the messages at my jooby application.

When I send multiple messages, I only get one and then later one more. It is really broken, I've spent so much time trying to debug this.

At first I noticed that in jooby's JettyWebSocket, this method never uses the callback and it is apparently the callback succeed which demands more messages.

public void onWebSocketBinary(ByteBuffer payload, Callback callback) {

I was thinking maybe it should implement the autodemand interface instead.

But then I tried with text messages and the issue still happens. and the on text method in jettywebsocket has no callback to use or not use.

to reproduce:

jooby server (jooby 4.0.11 with jooby-jetty 4.0.11):

ws("/*", (ctx, configurer) -> {
    configurer.onMessage((ws, message) -> {
        System.out.println(message);
    });
});

https://github.com/TooTallNate/Java-WebSocket client:

new WebSocketClient(URI.create("ws://127.0.0.1:8080")) {
	@Override
	public void onOpen(ServerHandshake handshakedata) {
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
		send("hi");
	}

	@Override
	public void onMessage(String message) {
	}

	@Override
	public void onClose(int code, String reason, boolean remote) {
	}

	@Override
	public void onError(Exception ex) {
	}
}.connect();

I'm pretty sure the issue is with jooby or one of jooby's dependencies, because I can see the messages sent without issue in wireshark, and when i try to use another java websocket server (for example the WebSocketServer of https://github.com/TooTallNate/Java-WebSocket) there is no issue either. i am using java version 25.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions