I'm using p: socket to open one socket per active channel, as follows:
Code: Select all
<p:socket widgetVar="#{id}-SKT" id="SKT-#{myBean.someId}" channel="/events/#{myBean.someId}" autoConnect="true" transport="websocket" fallbackTransport="long-polling">
<p:ajax event="message" listener="#{statusBean.update()}" update="westPanelGroup,@form,:contentForm" />
</p:socket>
Each time the ajax calls are triggered and some component is refreshed, if I use long polling, I see new GET requests being created with the same myBean.someId, all of them active, until the browser freezes. If I use websockets, after some clicking, I see the SecurityException being triggered, which indicates that there are too many open websockets.
The workaround I found for the moment is to manually close the sockets with onStart callbacks on every action, which is ugly and error-prone.
I think that PF should check if there is already a socket open for a certain channel before opening a new one, and either reuse it or close it.
Is there a way to do this by overriding the SocketRenderer, or do I have to modify the push.js to do this?
Thank you very much for your help!