But, once in a while, some client does not get any message.
After debugging some time I have found that when the client does not receive messages the onOpen in PushEndPoint resource class is called with <this> referencing to a same empty class!!, in such case PathParam is not initialized, apart from that, call stack in onOpen and execution appears exactly the same when it works and when it does not work.
To figure it out I set some code and log it, showed later.
I will appreciate any help.
Primefaces 5.0 (Public version)
Glassfish 4.0
Atmosphere-runtime 2.1.6 (also proved with 2.1.3)
The empty class which reference "this" once in a while (break in onOpen):
this PushResource (id=421)
sessionId null
PushResource.java content:
I have proved with singleton and without.
Code: Select all
package wda.utils;
import org.primefaces.push.EventBus;
import org.primefaces.push.RemoteEndpoint;
import org.primefaces.push.annotation.OnClose;
import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.OnOpen;
import org.primefaces.push.annotation.PathParam;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.annotation.Singleton;
import org.primefaces.push.impl.JSONEncoder;
@PushEndpoint("/events/{sessionId}/")
@Singleton
public class PushResource {
@PathParam("sessionId")
private String sessionId;
@OnMessage(encoders = {JSONEncoder.class})
public Object onMessage(Object pushData) {
return pushData;
}
@OnOpen
public void onOpen(RemoteEndpoint r, EventBus eventBus) {
if (sessionId == null)
System.out.println("<ERROR> Push connection not recognized, sessionId got <null>");
else
System.out.println("Push connection opened with sessionId " + sessionId);
}
@OnClose
public void onClose(RemoteEndpoint r, EventBus eventBus) {
if (sessionId == null)
System.out.println("Push connection with null sessionId closed");
else
System.out.println("Push connection closed with sessionId " + sessionId);
}
}
(Repeatedly open url from browser and close the browser) Using sometimes IE and others Chrome, no pattern regarding browser detected.
2014-08-04T11:15:08.674-0500|INFO: Push connection opened with sessionId 1cce1957482b86e33af34a97481c
2014-08-04T11:15:16.849-0500|INFO: Push connection closed with sessionId 1cce1957482b86e33af34a97481c
2014-08-04T11:15:29.134-0500|INFO: Tipo de Browser = Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0) Lenguage = 0
2014-08-04T11:15:30.241-0500|INFO: Push connection opened with sessionId 1cdd21ebb274aa207f7fe01f5225
2014-08-04T11:15:37.850-0500|INFO: Push connection closed with sessionId 1cdd21ebb274aa207f7fe01f5225
2014-08-04T11:16:15.689-0500|INFO: Push connection opened with sessionId 1cdd21ebb274aa207f7fe01f5225
2014-08-04T11:16:22.705-0500|INFO: Push connection closed with sessionId 1cdd21ebb274aa207f7fe01f5225
2014-08-04T11:16:29.039-0500|INFO: Tipo de Browser = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36 Lenguage = 0
2014-08-04T11:16:30.257-0500|INFO: <ERROR> Push connection not recognized, sessionId got <null>
2014-08-04T11:16:38.545-0500|INFO: Push connection with null sessionId closed
2014-08-04T11:17:24.803-0500|INFO: <ERROR> Push connection not recognized, sessionId got <null>
2014-08-04T11:17:33.008-0500|INFO: Push connection with null sessionId closed
2014-08-04T12:35:48.077-0500|INFO: Push connection closed with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:35:51.423-0500|INFO: Push connection opened with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:35:55.295-0500|INFO: Push connection closed with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:36:25.959-0500|INFO: Push connection opened with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:36:31.223-0500|INFO: Push connection closed with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:36:44.543-0500|INFO: Push connection opened with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:36:47.842-0500|INFO: Push connection closed with sessionId 2172508b3c103afd64ad9aa8c8c1
2014-08-04T12:36:59.619-0500|INFO: Tipo de Browser = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36 Lenguage = 0
2014-08-04T12:37:07.055-0500|INFO: <ERROR> Push connection not recognized, sessionId got <null>
2014-08-04T12:37:12.391-0500|INFO: Push connection with null sessionId closed
web.xml
atmosphere params was set and clear, no difference in behaviour.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="Test App_ID" version="3.1">
<display-name> etc etc </display-name>
<description>
Program ....
</description>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<!-- <context-param>
<param-name>primefaces.THEME</param-name>
<param-value>dev</param-value>
</context-param> -->
<context-param>
<param-name>primefaces.CACHE_PROVIDER</param-name>
<param-value>org.primefaces.cache.EHCacheProvider</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.icap</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.annotation.packages</param-name>
<param-value>org.primefaces.push</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.packages</param-name>
<param-value>wda.utils</param-value>
</init-param>
<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>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/META-INF/taglib.xml</param-value>
</context-param>
<context-param>
<param-name>primefaces.SUBMIT</param-name>
<param-value>partial</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
<param-value>65535</param-value><!-- 64KB -->
</context-param>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.xhtml</location>
</error-page>
<session-config>
<session-timeout>-1</session-timeout>
</session-config>
</web-app>
Code: Select all
<!-- Connection which will receive push notifications from server -->
<p:socket id="wdaPushing" onMessage="WDA.pushCallbackFunction" onError="WDA.pushErrorFunction" channel="/events/#{session.id}/" />
bean code:
Code: Select all
@ManagedBean(name = "DSession")
@SessionScoped
public class DSessionBean {
public EventBus eventBus;
public String session_id;
public String channel;
@PostConstruct
public void postInit() {
session_id = FacesUtils.getSessionId();
channel = "/events/" + session_id + "/";
eventBus = EventBusFactory.getDefault().eventBus();
}
public synchronized void makePush(Object objData){
eventBus.publish(channel, objData);
}
}
PushResource.onOpen(RemoteEndpoint, EventBus) line: 35
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
Invoker.invokeMethod(Method, Object, Object...) line: 49
PushEndpointHandlerProxy.invokeOpenOrClose(Method, RemoteEndpointImpl) line: 372
PushEndpointHandlerProxy$3.onSuspend(AtmosphereResourceEvent) line: 171
AtmosphereResourceImpl.onSuspend(AtmosphereResourceEvent) line: 640
AtmosphereResourceImpl.notifyListeners(AtmosphereResourceEvent) line: 587
AtmosphereResourceImpl.notifyListeners() line: 564
AtmosphereResourceImpl.suspend(long) line: 383
AtmosphereResourceLifecycleInterceptor.postInspect(AtmosphereResource) line: 119
GlassFishServ30WebSocketSupport(AsynchronousProcessor).postInterceptors(List<AtmosphereInterceptor>, AtmosphereResource) line: 323
GlassFishServ30WebSocketSupport(AsynchronousProcessor).action(AtmosphereRequest, AtmosphereResponse) line: 195
GlassFishServ30WebSocketSupport(AsynchronousProcessor).suspended(AtmosphereRequest, AtmosphereResponse) line: 98
GlassFishServ30WebSocketSupport.service(AtmosphereRequest, AtmosphereResponse) line: 60
AtmosphereFramework.doCometSupport(AtmosphereRequest, AtmosphereResponse) line: 1809
DefaultWebSocketProcessor.dispatch(WebSocket, AtmosphereRequest, AtmosphereResponse) line: 434
DefaultWebSocketProcessor.open(WebSocket, AtmosphereRequest, AtmosphereResponse) line: 187
GlassFishServ30WebSocketSupport$Grizzly2WebSocketApplication.onConnect(WebSocket) line: 144
DefaultWebSocket.onConnect() line: 202
WebSocketEngine.upgrade(FilterChainContext, HttpContent, Mapper) line: 229
WebSocketAddOnProvider$GlassfishWebSocketFilter.doServerUpgrade(FilterChainContext, HttpContent) line: 118
WebSocketAddOnProvider$GlassfishWebSocketFilter(WebSocketFilter).handleServerHandshake(FilterChainContext, HttpContent) line: 319
WebSocketAddOnProvider$GlassfishWebSocketFilter(WebSocketFilter).handleHandshake(FilterChainContext, HttpContent) line: 278
WebSocketAddOnProvider$GlassfishWebSocketFilter(WebSocketFilter).handleRead(FilterChainContext) line: 199
ExecutorResolver$9.execute(Filter, FilterChainContext) line: 119
DefaultFilterChain.executeFilter(FilterExecutor, Filter, FilterChainContext) line: 288
DefaultFilterChain.executeChainPart(FilterChainContext, FilterExecutor, int, int, DefaultFilterChain$FiltersState) line: 206
DefaultFilterChain.execute(FilterChainContext) line: 136
DefaultFilterChain.process(Context) line: 114
ProcessorExecutor.execute(Context) line: 77
TCPNIOTransport.fireIOEvent(IOEvent, Connection, IOEventProcessingHandler) line: 838
AbstractIOStrategy.fireIOEvent(Connection, IOEvent, IOEventProcessingHandler, Logger) line: 113
WorkerThreadIOStrategy.run0(Connection, IOEvent, IOEventProcessingHandler) line: 115
WorkerThreadIOStrategy.access$100(Connection, IOEvent, IOEventProcessingHandler) line: 55
WorkerThreadIOStrategy$WorkerThreadRunnable.run() line: 135
FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).doWork() line: 564
FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).run() line: 544
DefaultWorkerThread(Thread).run() line: 722