I am using PrimeFaces 5.0 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
<p:socket onMessage="jsFunctionToCall" channel="/service/push"/>
Web.xml
<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
@PushEndpoint("/service/push")
public class ServicePushResource {
@OnMessage(encoders = {JSONEncoder.class})
public String onMessage(String count) {
return count;
}
}
Pushing message:
EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/service/push", String.valueOf("msg"));
I am getting the error message that
WebSocket connection to 'ws://example.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
After this error there is another error message that
Websocket failed. Downgrading to Comet and resending push.js.xhtml?ln=primefaces&v=5.1:1 Failed to load resource: the server responded with a status of 501 (Not Implemented) http://example.com/primepush/service/push?X-Atmos…ng&X-Atmosphere-TrackMessageSize=true&X-atmo-protocol=true&_=1422008343786
On inspecting both the error message, I found that the p:socket component is failing with transport as 'WebSocket' and it is trying with 'long-polling' which is not implemented. So my question is whether AWS support 'WebSocket' if not what is the workaround for that?