quarkus-http icon indicating copy to clipboard operation
quarkus-http copied to clipboard

WebSocket: Support Servlets using Undertow

Open melloware opened this issue 1 year ago • 9 comments

Original MyFaces issue: https://issues.apache.org/jira/projects/MYFACES/issues/MYFACES-4684

MyFaces allows users to do this...

<f:websocket scope="session" channel="pushChannel" onmessage="function(m){console.log(m);}">
                    <f:ajax event="quarkusMessage" render="frmSocket:txt_count"/>
</f:websocket>

A websocket can be associated to a particular USER or Session so only that session sees messages on that channel. This no longer works because here:

https://github.com/apache/myfaces/blob/1e369ebb8e569f5bbb08912e66dbb978c1d2483b/impl/src/main/java/org/apache/myfaces/push/WebsocketConfigurator.java#L48-L88

The value for HandshakeRequest request using request.getSession() is always NULL and thus breaks this code and websockets do not work.

melloware avatar Oct 22 '24 17:10 melloware

Image

melloware avatar Nov 07 '24 13:11 melloware

what do you mean by a mock-session? It needs to be the same as the HttpSession, which is available during a JSF request.

tandraschko avatar Nov 07 '24 13:11 tandraschko

cc @cescoffier

melloware avatar Nov 07 '24 13:11 melloware

It won't have the semantic of the http session, it will be the same API with a very limited life span (the request). It's clearly a hack, there is no plan to support proper http session right now.

cescoffier avatar Nov 07 '24 15:11 cescoffier

im not sure if this will work AFAIR we store some verification information in the HttpSession (currently SessionScoped bean), but we could switch to HttpSession#attributes

if both attributes are not the same, there is no benefit in itnroducing a short-living fake-session.

Maybe we need to check if the verification is required or at least deactivate it for quarkus environment.

tandraschko avatar Nov 07 '24 15:11 tandraschko

Is there a plan to get this working again or should I try to find a different technology to achieve my goals? I am porting an application that was running on Wildfly using WS to notify the JSF front-end when certain things were updated.

dstutz avatar Jan 30 '25 19:01 dstutz

@dstutz As a workaround....you can use OmniFaces Socket that works with Quarkus.

see: https://quarkus-faces-melloware-8a6a34c1.koyeb.app/ui/ajax/websocket.xhtml

melloware avatar Jan 30 '25 19:01 melloware

@melloware ,nm.....got a replication of your example working. This stuff is black magic to get working. Thank you!

dstutz avatar Jan 30 '25 19:01 dstutz

no problem yeah you have to follow the Omnifaces WebSockets instructions!

melloware avatar Jan 30 '25 20:01 melloware