You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WebSocketClient.setClient can't borrow a client created without a Context #1599
With #1568, WebSocketClient.setClient(Client) lets a WebSocket client share a borrowed client's event loop. It finds the client's NettyClientHelper through the org.restlet.engine.helper context attribute, so it only accepts a client that has a Context.
The most common way to create a client is new Client(Protocol.HTTP), and that client has no context, so it can't be borrowed. start() throws:
The borrowed client must have a context and use the Netty HTTP connector
The workaround is new Client(new Context(), Protocol.HTTP). It's shown in the #1568 description, but it's easy to miss, and the error doesn't say what to change.
Why it matters
setClient is meant to accept the client an application already has. The GraphQL WebSocket client (#1594) borrows the application's client the same way and inherits this restriction.
Proposed direction
Find the helper without going through the context, for example with an engine-level accessor on Client. That way any started client that uses the Netty connector can be borrowed.
Otherwise, keep the context lookup, document the requirement on setClient, and name the fix in the error message.
Activity