-
Notifications
You must be signed in to change notification settings - Fork 43
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
Handle websocket in dev-mode or document that it is not forwarded (HMR) #71
Comments
When stopping the dev mode, it might end up with an exception:
|
@cescoffier any idea on how we could listen/forward websocket events? |
Did you look at https://vertx.io/docs/vertx-core/java/#_websockets? |
@cescoffier yes I did. But here are my issues:
|
I don't understand your first point. Web sockets are not a publish/subscribe thing, it's end to end. About the second point, do you have a channel of communication? A web socket maybe? About the third point, yes, but a simple route upgrading the connection to a web socket is generally much better. |
@cescoffier maybe you can help here. We receive a WebSocket request on 8080 but we need to forward it to 3000 (NextJS). if (headers.get("Connection").contains("Upgrade")) {
LOG.infof("Quinoa is forwarding web socket: '%s'", request.uri());
Future<ServerWebSocket> fut = request.toWebSocket();
fut.onSuccess(serverWs -> {
LOG.infof("Quinoa is forwarded web socket: '%s'", request.uri());
WebSocketConnectOptions options = new WebSocketConnectOptions()
.setHost(request.localAddress().host())
.setPort(port)
.setURI(uri)
.setAllowOriginHeader(false);
httpClient.webSocket(options, res -> {
WebSocket clientWs = res.result();
clientWs.pipeTo(serverWs);
serverWs.pipeTo(clientWs);
LOG.infof("Connected! ");
});
}); But essentially the goal is we are trying to forward and 8080 WebSocket to 3000 and keep it open for two way communication. I can see the Next ping-pong but something still isn't working. |
I got it all working for both NextJS and Vite. PR on the way... |
Some NodeJS dev-server don't allow to set the websocket port for for hot reload. Currently those websocket connection are not forwarded by Quinoa.
Some other dev-server like Vite allow to change the HMR port, then http is sent and forwarded by Quinoa and HMR is sent to the frontend dev-server (which works great).
The text was updated successfully, but these errors were encountered: