Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket client: make it possible to supply a custom eventLoop context #5366

Open
mkouba opened this issue Oct 23, 2024 · 0 comments · Fixed by #5368
Open

WebSocket client: make it possible to supply a custom eventLoop context #5366

mkouba opened this issue Oct 23, 2024 · 0 comments · Fixed by #5368
Assignees
Milestone

Comments

@mkouba
Copy link

mkouba commented Oct 23, 2024

As discussed on Discord it would make sense to add the possibility to supply a custom eventLoop context when a new WebSocket is connected.

Currently, when you connect a new Websocket it takes the current context that is used to send messages etc. This means that if you connect multiple clients in a row they will use the same event loop and so writing/receiving messages is de facto serialized.

The workaround is to create a new eventLoop context and dispatch the connection logic:

Context context = ((VertxImpl) vertx).createEventLoopContext();
context.dispatch(v -> { 
   // vertx.createWebSocketClient().connect()...
}

In Vertx4, we could add the eventLoopContext to the WebSocketConnectOptions and then use it in HttpClientBase#webSocket(WebSocketConnectOptions, PromiseInternal<WebSocket>) if not null. Alternatively, we could add something like io.vertx.core.http.impl.WebSocketClientImpl#webSocket(ContextInternal).

Use cases

In Quarkus, we will use the aforementioned workaround in the mean time: quarkusio/quarkus#44039

@vietj vietj added this to the 4.5.11 milestone Oct 23, 2024
@vietj vietj self-assigned this Oct 23, 2024
@vietj vietj modified the milestones: 4.5.11, 4.5.12 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants