I am trying to implement SSE in WildFly 26 for our web application. Unfortunately it is being done on a corporate network so I can't attach source. I have it working with http, so I know my code is good. However, our product is using https with a username/password login that returns a session ID cookie (authentication is implemented using Shiro). When I test in this environment, the SSE stream seems to close as soon as it returns from the @GET MediaType.SERVER_SENT_EVENTS registration endpoint.
In the registration endpoint, I register the caller's SseEventSink with my SseBroadcaster and then create an OutboundSseEvent to let the client know that registration is successful. After logging the call, I send the confirmation OutboundSseEvent directly to the caller's SseEventSink before exiting the method.
I use curl to test with so I first run:
I then run:
Curl prints out header information including:
HTTP/1.1 200 OK
Connection: keep-alive
Transfer-Encoding: chunked
Content-Type: text/event-stream
I then see a printout of my registration confirmation event followed immediately by:
* Connection #0 to host localhost left intact
and then I am given my command prompt back.
I take this to mean that curl believes my stream has closed and exits. When I tested my prototype SSE war (in the same WildFly instance) using just a plain http endpoint, curl waited forever and printed out every broadcast event I throw at it -- it was great!
Since I am confident my SSE Java code works properly (thanks to the http experiment I did) I have been doing a lot of Googling about what might be different with SSE over https and what WildFly configuration changes I might need to make. So far, that search has been in vain. I am no closer to finding a solution to my problem than I was last week.
I can't copy/paste my standalone.xml file but I think this is the relevant part of the undertow configuration, in case that helps:
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https-pki" socket-binding="https-pki" no-request-timeout="-1" ssl-context="crowbarSSC" enable-http2="true"/>
<https-listener name="https" socket-binding="https" ssl-context="applicationSSC" enable-http2="true"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<http-invoker http-authentication-factory="application-http-authentication"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<application-security-domains>
<application-security-domain name="other" security-domain="ApplicationDomain"/>
</application-security-domains>
Any thoughts on what I might have done wrong or might need to do that I haven't done yet would be greatly appreciated.
Thanks,
Erik