PushEndPoint resource class once in a while is empty

UI Components for JSF
pslzr
Posts: 11
Joined: 12 Jun 2012, 17:21

07 Aug 2014, 18:13

[quote="kukeltje"]I don't think the problem is caused by push but by some other more generic issue.
.......

Thanks kukeltje.

I have reviewed network messages for two hours, comparing html and cookies, those when sessionId got null and push does not work against those in which sessioId is correct and push works.

In a brief I did not find difference. The only difference is directive <jsessionid>, which obviously changes in each session, and it exist in html code in both scenarios.

Lets say for example,
when works well:
<script id="j_idt9:wdaPushing_s" type="text/javascript">$(function(){PrimeFaces.cw("Socket","widget_j_idt9_wdaPushing",{id:"j_idt9:wdaPushing",widgetVar:"widget_j_idt9_wdaPushing",url:"/WDA/primepush/events/0ccbf832d7013d42077da6d71754/;jsessionid=0ccbf832d7013d42077da6d71754",autoConnect:true,transport:"websocket",fallbackTransport:"long-polling",onMessage:WDA.pushCallbackFunction,onError:function(response){WDA.pushErrorFunction}});});</script><span id="j_idt9:txt_value" style="display:none;">txt</span><script id="j_idt9:j_idt11_s" type="text/javascript">$(function(){PrimeFaces.cw("Poll","pollConnection",{id:"j_idt9:j_idt11",widgetVar:"pollConnection",frequency:22,autoStart:true,fn:function(){PrimeFaces.ab({s:'j_idt9:j_idt11',f:'j_idt9',u:'j_idt9:txt_value',ps:true,oner:function(xhr,status,error){pollConnection.stop(); alert('Closed Session'); location.reload();G_reload_page=true;G_disconnected=true;;}});}});});</script><input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="-2782688223628478633:-1483531104748026338" autocomplete="off" />

when fails :
<script id="j_idt9:wdaPushing_s" type="text/javascript">$(function(){PrimeFaces.cw("Socket","widget_j_idt9_wdaPushing",{id:"j_idt9:wdaPushing",widgetVar:"widget_j_idt9_wdaPushing",url:"/WDA/primepush/events/0e618c8e793aabcd76e65b69dc3e/;jsessionid=0e618c8e793aabcd76e65b69dc3e",autoConnect:true,transport:"websocket",fallbackTransport:"long-polling",onMessage:WDA.pushCallbackFunction,onError:function(response){WDA.pushErrorFunction}});});</script><span id="j_idt9:txt_value" style="display:none;">txt</span><script id="j_idt9:j_idt11_s" type="text/javascript">$(function(){PrimeFaces.cw("Poll","pollConnection",{id:"j_idt9:j_idt11",widgetVar:"pollConnection",frequency:22,autoStart:true,fn:function(){PrimeFaces.ab({s:'j_idt9:j_idt11',f:'j_idt9',u:'j_idt9:txt_value',ps:true,oner:function(xhr,status,error){pollConnection.stop(); alert('Closed Session'); location.reload();G_reload_page=true;G_disconnected=true;;}});}});});</script><input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="8162960213548174238:-3623140348150622308" autocomplete="off" />

Same with cookies, equal when works and when fails.

I you could guide something more specific to look for, I will glad to do so.

pslzr
Posts: 11
Joined: 12 Jun 2012, 17:21

07 Aug 2014, 19:00

smithh032772 wrote:okay, revisiting this below,
...

i wonder if the issue is caused by your code below,
....

in my app, I don't do this,

Code: Select all

    @PostConstruct
    public void postInit() {

        ...

        eventBus    = EventBusFactory.getDefault().eventBus();
    }
Good point!, I have already also wondered it.
Let say, that doing so could lead to an incorrect initialization of "eventBus", (which should make publish work incorrect).
Then,
Why onOpen method which is directly related to Push connection initialization goes incorrect with initializing sessionId? So, I conclude, onOpen calling moment and sessionId initialization apparently has nothing to do with the eventBus initialization.
I have reviewed previously eventBus initialization and it appears not related to the moment is called.
Have already inserted eventBus initialization in the exact moment of publishing and it does not solve the problem.
smithh032772 wrote: I searched google for the following:
site:forum.primefaces.org pushnotification userpushingmessage
and I found
Re: Push message when user disconnects?
Thanks, logout implementation has already be done. But in this scenario we maintain old fashion to be sure session remains long after browser is closed.
smithh032772 wrote: and I found
Push with threads
Thanks again, we already have a working push with old Primefaces. But we want p:cache recently implemented in Primefaces 5.0 to increase performance. Primefaces 5.0 has changed push interface.

Are you using successfully old push fashion coding way in this last new brand Primefaces 5.0?

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

07 Aug 2014, 19:44

I am using PrimeFaces Push, but I migrated my code to PrimeFaces Push 5.0, so the code that I shared in

Re: Push message when user disconnects?

is still the same, but it has been migrated to PrimeFaces Push 5.0 (eventBus, etc...). Also, that code that I shared is not only for 'logout' example. it is an example of how I use one eventBus (@applicationscoped) to push messages to 'every' user session, separately. i have for/loop and send separate/same message to every channel; every channel = every separate user session.

i think your eventBus should be declared like mine, final, in @ApplicationScoped bean, instead of @PostConstruct on @SessionScoped bean.

also, i think PrimeFaces Push in 'your app' is heavily dependent on glassfish websocket library, but I could be wrong. i'm using tomee/tomcat7.
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

pslzr
Posts: 11
Joined: 12 Jun 2012, 17:21

08 Aug 2014, 00:55

Thanks smithh032772.
smithh032772 wrote:
.....

i think your eventBus should be declared like mine, final, in @ApplicationScoped bean, instead of @PostConstruct on @SessionScoped bean.
Just to point out again that eventBus is used far beyond after onConnect occurs, which means it is not the source of the problem. As stated, I also withdraw eventBus from postConstruct and use it only when publishing as many Primefaces 5.0 samples are doing. Look one sample:

Code: Select all

  public void publish() {
        EventBus eventBus = EventBusFactory.getDefault().eventBus();
        eventBus.publish("/checkin", checkin);
    }
Of course, that did not help to solve the problem.
smithh032772 wrote:
also, i think PrimeFaces Push in 'your app' is heavily dependent on glassfish websocket library, but I could be wrong. i'm using tomee/tomcat7.
It is good to know it works in your tomee/tomcat7.
I wonder if someone can tell me how it worked when using in glassfish 4.0, previously to think on tomee/tomcat7.

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

08 Aug 2014, 19:36

I wanted to return the following, because i discussed this sometime earlier on in this forum.

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;   
I searched this PrimeFaces Push forum for

singleton

and found the following

Re: @Inject in @PushEndpoint

Re: PF5 RC1 - Push Showcase chat - EventBusFactory NPE..

please review the forum topics above and the recommendations and the code discussed. maybe they can help. personally, I don't recommend the following:

Code: Select all

    @PathParam("sessionId")
    private String sessionId;   
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

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

11 Aug 2014, 10:47

smithh032772 wrote:personally, I don't recommend the following:

Code: Select all

    @PathParam("sessionId")
    private String sessionId;   
Why not?

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

11 Aug 2014, 16:21

kukeltje wrote:
smithh032772 wrote:personally, I don't recommend the following:

Code: Select all

    @PathParam("sessionId")
    private String sessionId;   
Why not?
what benefit does it serve when sessionId == null? as you can see below, sessionId == null just before session ends (or 'destroyed', or 'removed', as you stated earlier, Ronald). if session really has not been destroyed but sessionId == null, then this pathparam sessionId approach should not be used. sessionId should 'not' be NULL before (http)session is removed/destroyed, but maybe this pathparam sessionId is implemented to be NULL before httpsession is removed. I don't recommend using pathparam sessionId and I don't use it, because I use a different approach to get http session ID to uniquely identify push paths. i provided a URL to my code that I shared months/year ago. :)
pslzr wrote:And, obtained result for your consideration:

Code: Select all

2014-08-06T10:41:32.278-0500|INFO: Session started with bfb80b2f9f8e61d643118747241d
2014-08-06T10:41:33.612-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-06T10:41:33.745-0500|INFO: Push connection opened with sessionId bfb80b2f9f8e61d643118747241d
2014-08-06T10:41:41.334-0500|INFO: Push connection closed with sessionId bfb80b2f9f8e61d643118747241d
2014-08-06T10:41:53.214-0500|INFO: [color=#4000FF]Session started[/color] with bfbd2ba32409df6bb4b4405b5257
2014-08-06T10:41:53.703-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-06T10:41:53.745-0500|INFO: [color=#BF0040]<ERROR> Push connection not recognized, sessionId got <null>[/color]
2014-08-06T10:42:06.406-0500|INFO: Push connection with null sessionId closed
2014-08-06T10:43:07.961-0500|INFO: Session ended with bfb80b2f9f8e61d643118747241d
2014-08-06T10:43:48.104-0500|INFO: [color=#4000FF]Session ended[/color] with bfbd2ba32409df6bb4b4405b5257
2014-08-06T10:43:55.060-0500|INFO: Session started with bfdaeb1985a5b411247835663f3e
2014-08-06T10:43:55.532-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-06T10:43:55.572-0500|INFO: Push connection opened with sessionId bfdaeb1985a5b411247835663f3e
2014-08-06T10:44:05.859-0500|INFO: Push connection closed with sessionId bfdaeb1985a5b411247835663f3e
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

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

11 Aug 2014, 19:10

if the user 'disconnects', these events should not fire anymore, so it should not be a problem that sessionId is null then since one should not get there (afaict). Or do I miss something?

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

11 Aug 2014, 19:49

Okay. Are you basically saying that OP should not be concerned about sessionId == null, and if sessionId == null, then return (or exit the method)?
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

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

12 Aug 2014, 17:22

Well, the OP was wondering WHY it was null. Might just be that it is some 'cache' mechanism in PF Push/Atmosphere that does not know the connection was already gone and still tries to push it or any other strange reason.

Ignoring it being null is only valid if there is no abnormal behaviour

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests