Skip to content

WebSocketClient.connect() throws IllegalStateException: Should call init(endpoint) with an async EndpointGroup #6839

Description

@aakugan

Description

I think I hit a bug in the WebSocket client. When a WebSocketClient is built over an EndpointGroup whose selectNow() returns null and resolves asynchronously via select() (service-discovery-backed groups, a cold DynamicEndpointGroup, etc.), connect() fails immediately with:

java.lang.IllegalStateException: Should call init(endpoint) before invoking this method.
at com.linecorp.armeria.internal.client.DefaultClientRequestContext.eventLoop(DefaultClientRequestContext.java:825)
at com.linecorp.armeria.client.websocket.DefaultWebSocketClient.connect(DefaultWebSocketClient.java:110)

A WebClient over the same group works fine (it waits for selection), so it looks specific to the ws path.
iiuc the cause is the eager use of ctx.eventLoop here
Minimal repro (jbang, Armeria 1.39.0).

Please correct me if I'm misreading this and async EndpointGroups aren't intended to be supported by the WebSocket client.
I'd like to pick this up and put together a fix, happy to align on the approach first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions