Reputation: 121
I'm modifying the handshake of Websocket by implementing ServerEndpointConfig.Configurator and overriding 'modifyHandshake', but the code is blocking and running on an IO thread, how can I force it to run on a worker thread?
'quarkus.websocket.dispatch-to-worker=true' is working only for @serverendpoint @onopen.
I tried to annotate the 'modifyHandshake' with @Blocking but still - it's running on an IO thread.
Expected behavior - modifyHandshake should be invoked on a worker thread.
Actual behavior modifyHandshake invoked on an IO thread.
How to Reproduce?
public class WebSocketEndpointConfigurator extends ServerEndpointConfig.Configurator {
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
// executing blocking code
Thread.sleep(3000)
}
}
WARN [io.vertx.core.impl.BlockedThreadChecker] (vertx-blocked-thread-checker) Thread Thread[vert.x-eventloop-thread-7,5,main] has been blocked for 128597346 ms, time limit is 2000 ms: io.vertx.core.VertxException: Thread blocked
Quarkus 2.4.1.Final
Upvotes: 1
Views: 171
Reputation: 133
i had the same issue.
i solved it by moving the code that was "blocking" from the modifyHandshake
method into the onOpen
method.
modifyHandshake
runs on an eventloop threadonOpen
method runs on a executor thread.config.getUserProperties()
.onOpen
method and i didnt block any more.hope it helps.
Upvotes: 1