PushServlet and and JavaEE websockets

UI Components for JSF
Post Reply
antgamdia
Posts: 1
Joined: 23 Oct 2014, 18:11

24 Oct 2014, 17:26

Hello,

we are using primepush to send all push notifications and everything was going well. Recently we decided to support webRTC with Kurento. It uses JavaEE websockets directly to communicate with the server, so we added a @ServerEndpoint("/whatever").
The push servlet should only map endpoints starting with "/primepush".

We open the websocket pointing to, for example, "/webrtc", but, although the handsake is made, we obtain no response from the server. I though it is a problem caused by servlet mapping: probbably there is a bug, and all server endpoints are mapped to prime push servlet.

If we remove the selected web.xml portion below, JavaEE websockets work perfect, but primepush notifications do not.

What can I do? Does anyone know a solution or maybe just a workaround?

Update:

- If we remove pushServlet and use javax.websockets, everything is going well. Even we can access to the session context and launch CDI events after it finishes processing.

- If we use pushServlet and map this servlet to something different from "/primepush", it does not work (302 response and sockets continue generating the "/primepush" uri).

- If instead of using JavaEE serverEndPoint we map the pushServlet to "/primePush, this works well and messages arrive. Although, this PushEndPoint seems to be out of any context: we cannot use anyhing related with CDI, injections... neither accessing by instances, CDI.context nor context.lookup("java:com/BeanManager") we can access to beanManager.

- If we substitute PushEndPoint handler from WebSocketHandler we obtain the same result that we got using PushEndPoint. Inside the method "onOpen" there is nothing injected and we cannot access CDI context as well. Looking up the documentation, it explicitly says that CDI can be used, so.... what is happening?

- If we add @PostConstruct to the @PushEndPoint, now it seems the resource has been successfully injected. Nevertheless, the bean is risen when the application starts (I guess it is PushServlet who rise it). The weird thing is that when we add @PostConstruct annotation, neither onOpen nor onMessage methods are called.

- It seems clear that PushServlet (i.e. AtmosphereServlet) is working a bit weirdly. Because of this servlet is one of the firsts and handles all servlets and CDI requests, everything is going bad.

Now we are choosing between CDI or PushServlet, we no longer use Atmosphere. Pros: we are using standard websocket. Cons: we lost compatibility with IE8 and IE9.

We use:
  • JavaEE 7
  • Primefaces 5.1
  • Atmosphere 2.2.3
  • Glassfish 4.1b13 Stable
Web.xml

Code: Select all

    <servlet>
        <servlet-name>Push Servlet</servlet-name>
        <servlet-class>org.primefaces.push.PushServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>Push Servlet</servlet-name>
        <url-pattern>/primepush/*</url-pattern>
    </servlet-mapping>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests