#57079·quarkus

WebSockets Next: client back-pressure stalls a connection receiving fragmented messages

Author: CrowayCreated Oct 1, 2026Updated Oct 1, 2026
Labelsarea/websockets

Describe the bug

With client back-pressure (quarkus.websockets-next.client.max-pending-messages, new in 3.40), BasicWebSocketConnectorImpl calls ws.fetch(maxPendingMessages) and then ws.fetch(1) once per text/binary message processed. The Vert.x demand counts frames, not messages (WebSocketImplBase puts every TEXT/BINARY/CONTINUATION frame in its InboundBuffer; only PING/PONG fetch one more themselves). A message received in N frames consumes N and gives back 1, so the connection eventually stops reading: no more messages, and no pongs either.

Vert.x/Quarkus servers split messages over 64 KB into frames, so with the default of 256 a client that regularly receives such messages stalls after a while.

Expected behavior

All messages are delivered, whatever the number of frames per message.

Actual behavior

The client stops receiving. With max-pending-messages=4 and messages of 2 frames, only 3 of 10 messages are received.

How to Reproduce?

Test for extensions/websockets-next/deployment/src/test/java/io/quarkus/websockets/next/test/client/ (fails on 3.40.1 with [3 of 10 messages received]):

java
package io.quarkus.websockets.next.test.client;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusExtensionTest;
import io.quarkus.websockets.next.BasicWebSocketConnector;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;

public class BasicConnectorFragmentedMessagesBackPressureTest {

    @RegisterExtension
    public static final QuarkusExtensionTest test = new QuarkusExtensionTest()
            .withApplicationRoot(root -> {
            })
            // a small window, so that a few messages are enough
            .overrideRuntimeConfigKey("quarkus.websockets-next.client.max-pending-messages", "4")
            .overrideRuntimeConfigKey("quarkus.websockets-next.client.max-message-size", "1048576");

    @Inject
    Vertx vertx;

    @Inject
    BasicWebSocketConnector connector;

    @Test
    void receivesAllMessagesSentInSeveralFrames() throws Exception {
        // the server splits each message into 2 frames (its default max frame size is 64 KB)
        String message = "x".repeat(100 * 1024);
        int count = 10;
        HttpServer server = vertx.createHttpServer()
                .webSocketHandler(ws -> {
                    for (int i = 0; i < count; i++) {
                        ws.writeTextMessage(message);
                    }
                })
                .listen(0).toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
        try {
            CountDownLatch received = new CountDownLatch(count);
            connector.baseUri("ws://localhost:" + server.actualPort())
                    .onTextMessage((c, m) -> received.countDown())
                    .connectAndAwait();

            assertThat(received.await(10, TimeUnit.SECONDS))
                    .as("%d of %d messages received", count - received.getCount(), count)
                    .isTrue();
        } finally {
            server.close().toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
        }
    }
}

Output of uname -a or ver

Darwin 27.0.0

Output of java -version

openjdk 25.0.2 (Temurin)

Quarkus version or git rev

3.40.1 (same code on main at cd8646d2438)

Build tool (ie. output of mvnw --version or gradlew --version)

Maven 3.9.16

Additional information

Fetching one more for every non-final data frame (e.g. from a frameHandler) makes the test pass. Workaround: quarkus.websockets-next.client.max-pending-messages=0.