p:socket opens many websockets / long polling gets

UI Components for JSF
Post Reply
polluxmdq
Posts: 1
Joined: 12 Nov 2015, 13:04

12 Nov 2015, 13:20

Hello,

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>
In the page there are several actions that trigger ajax calls, and that will update or refresh some view components.

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!

henningk
Posts: 1
Joined: 20 Jan 2017, 14:45

10 May 2017, 17:45

Hi,
i know this is an old thread....
But i had the same problem and my solution was to move the <p:socket> outside of a form sorrounding the components to update.
Hope this helps someone.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests