I am writing a application which will upgrade the HTTP connection to a WebSocket connection. I'm building the application over Netty. I'm using below code block to trigger the connection upgrade.
WebSocketServerHandshakerFactory wsFactory =
new WebSocketServerHandshakerFactory(getWebSocketURL(req), null, true);
handshaker = wsFactory.newHandshaker(req);
if (handshaker == null) {
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
} else {
handshaker.handshake(ctx.channel(), req);
}
- When I try to upgrade the connection using above code from
channelReadmethod of a InBoundHandler, Upgrade process works fine. - When I try to trigger upgrade in
readorwritemethod of OutBoundHandler, I don't see anything on Wireshark. Feels like the request is just stuck somewhere and nothing is happening. (I have a use case to delay the upgrade).
Does WebSocket upgrade only works if triggered from InBoundHandler?