Primeface push with AWS

UI Components for JSF
Post Reply
vineethng
Posts: 4
Joined: 30 Jan 2014, 15:55

28 Jan 2015, 07:49

I am using PrimeFaces 5.1, atmosphere 2.2.2 and tomcat 7 and my application is in AWS. I am trying to use PrimeFaces push. I have implemented a sample application and it is working with my local system.
If i deploy the code to AWS it fails.

Xhtml Code

Code: Select all

<p:socket onMessage="jsFunctionToCall" channel="/service/push"/>
Web.xml

Code: Select all

<filter>
    <filter-name>shiroFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
      <param-name>targetFilterLifecycle</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name>
        <param-value>org.atmosphere.interceptor.ShiroInterceptor</param-value>
      </init-param>
  </filter>
  <filter-mapping>
    <filter-name>shiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <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>
Java code

Code: Select all

@PushEndpoint("/service/push")
public class ServicePushResource {
    @OnMessage(encoders = {JSONEncoder.class})
    public String onMessage(String count) {
        return count;
    }
}
Pushing message:

Code: Select all

EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/service/push", String.valueOf("msg"));
Error message that i get in browser console

WebSocket connection to 'ws://domain.com/primepush/service/push?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.4-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&X-atmo-protocol=true' failed: Error during WebSocket handshake: Unexpected response code: 501

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

29 Jan 2015, 10:04

Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

vineethng
Posts: 4
Joined: 30 Jan 2014, 15:55

11 Feb 2015, 14:54

The problem was with AWS as aws dont support Websocket. So I did some workaround by changing loadbalancer protocol from HTTP to TCP. Now the problem is the URL, If i specifu HTTPS in URL after login the application redirects to HTTP. So for this I specified the push server url in web.xml. So that my application listens to another url outside AWS. This is partially working as a message send from push server is received in my application. But if I send a message from my application to push server it is no sending. The problem might be because when my application is executing eventbus.push() it is not considering the url specified in the web.xml

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 39 guests