I'm using:
Linux
PrimeFaces 3.4.1
Glassfish 3.1.2.2 (build 5, with comet enabled, websockets disabled)
FireFox 10.0.7
Chromium 22.0.1229.94
I have PrimePush within a message-driven bean. When my MDB's onMessage() is called (which should be several times a second), I'm expecting growl notifications to appear. Also, not sure if this matters, but the MDB is in a *.jar file inside an *.ear, and the web application is in a *.war also inside the ear. I have PrimePush within the MDB as follows.
pushContext = PushContextFactory.getDefault().getPushContext();
pushContext.push("/notifications",
new FacesMessage("Hello World", "New Notification"));
Here's my web.xml.
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
The problem is a notification fires once when I bring everything up clean the first time (glassfish, browsers) but usually does not appear again or each time pushContext.push() is called thereafter. With FF, it doesnt' even work once. When the MDB onMessage() fires, I receive the following in the firefox error console shortly after.
Error: Firefox can't establish a connection to the server at ws://localhost:8080/test/primepush/notifications?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.0&X-Atmosphere-Transport=websocket&X-Cache-Date=0.
Source File: http://localhost:8080/test/javax.faces.resource/push/push.js.xhtml?ln=primefaces
Line: 1
Using Chrome, it does work at least once, sometimes but not reliably more. Each time I load the web page I see that a connection was closed (just as I was loading the page). This was within the error console.
Unexpected response code: 200 :8080:1
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). push.js.xhtml:1
Websocket closed, wasClean: false push.js.xhtml:1
Websocket failed. Downgrading to Comet and resending
Here is my text.xhtml page.
<p:growl widgetVar="growl" showDetail="true"/>
<h:form id="myform">
<p:fieldset id="myfs" legend="Push Test">
<!-- stuff -->
</p:fieldset>
</h:form>
<script type="text/javascript">
function handleMessage(data) {
data.severity = 'info';
growl.show([data]);
}
</script>
<p:socket onMessage="handleMessage" channel="/notifications">
</p:socket>
I was facing the same problem, and enabling websockets in glassfish fixed my problem (add following to domain.xml after comet-support-enabled):
websockets-support-enabled="true"
The hint was this:
Websocket failed. Downgrading to Comet and resending
According to the documentation here http://www.primefaces.org/docs/vdl/3.4/primefaces-p/socket.html , websocket was the default way used in primepush, which needs websockets to be enabled in glassfish. I think setting transport to comet (long-poll/stream) in p:socket might also work.
BTW, I tested on:
Mac
PrimeFaces 3.4.2 with Atmosphere 1.0.8
Glassfish 3.1.2 (with comet enabled, websockets enabled)
FireFox 18
Chromium 24