PushEndPoint resource class once in a while is empty

UI Components for JSF
smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

12 Aug 2014, 17:28

kukeltje wrote: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.
maybe
kukeltje wrote:Ignoring it being null is only valid if there is no abnormal behaviour
i agree.
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

13 Aug 2014, 18:32

smithh032772 wrote:
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).....
Sorry to say smithh032772 that asseveration is false, session is opened before onOpen is called, you can see en logs, and session is closed far beyond the browser is closed,
which means clearly that sessionId == null "just before" isessions ends or 'destroyed' or 'removed' is FALSE.

Even more, the exact moment I opened the url, onOpen is called, (after session has started).

Even more, the exact moment the browser is closed, onClose is called. Which means the session is totally valid, from before onOpen is called and after onClosed is called.

These occurre always when sessionId is null and when is not, observe that session_id in session always has the correct value. Even in the html viewed by the client (in the channel).
Last edited by pslzr on 14 Aug 2014, 16:52, edited 1 time in total.

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

13 Aug 2014, 21:08

Are these tests by you or observations from logging on a production system with numerous different users? In that case it could be they don't accept cookies and sessionId is not present for that reason. Can you add an addtional parameter in the push path to differentiate and maybe get some more info

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

14 Aug 2014, 18:30

kukeltje wrote:Are these tests by you or observations from logging on a production system with numerous different users? In that case it could be they don't accept cookies and sessionId is not present for that reason. Can you add an addtional parameter in the push path to differentiate and maybe get some more info
Thanks kukeltje,

Tests are conducting several ways,

1)
Open Chrome browser, just one instance, ensure all are closed,
set url,
some seconds after page is viewed, close browser, (push connection is also viewed closed always).
Repeat from starting until case null session id appears in onOpen, sometimes occurs first time too.

2)
Open different Chrome browser session concurrently running with --user-data-dir each one, open url, until case null session id occurs.

3)
Start server, (ensure configured to do not maintain sessions)
Start browser, set url,
If null session id does not occur, Stop server, close browser and repeat test again.

I have changed code, do not understand clearly your purpose, sorry to say that, may be you can clarify better for me.

Result:
2014-08-14T10:40:55.609-0500|INFO: Session started with 52dd1b5edf86be0b3de4d3e564fc
2014-08-14T10:40:56.281-0500|INFO: Tipo de Browser = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Lenguage = 0
2014-08-14T10:40:56.430-0500|INFO: Push connection opened with randomSession 3a20b3dc-ceb8-4648-95c6-d8876b3f1029
2014-08-14T10:41:08.589-0500|INFO: Push connection closed with randomSession 3a20b3dc-ceb8-4648-95c6-d8876b3f1029
2014-08-14T10:41:13.684-0500|INFO: Session started with 52e185194931fcd19d4eb762ca8c
2014-08-14T10:41:14.129-0500|INFO: Tipo de Browser = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Lenguage = 0
2014-08-14T10:41:14.176-0500|INFO: <ERROR> Push connection not recognized, randomSession got <null>
2014-08-14T10:42:27.631-0500|INFO: Session ended with 52dd1b5edf86be0b3de4d3e564fc
2014-08-14T11:16:34.573-0500|INFO: Push connection with null randomSession closed
2014-08-14T11:17:27.682-0500|INFO: Session ended with 52e185194931fcd19d4eb762ca8c


Code xhtml:

Code: Select all

<p:socket id="wdaPushing" onMessage="WDA.pushCallbackFunction" onError="WDA.pushErrorFunction" channel="/events/#{DSession.be}/" /> 

DSession (bean)

Code: Select all

@ManagedBean(name = "DSession")
@SessionScoped
public class DSessionBean implements AdminConnection.INotifyConnection{

    public String getBe()
    {
        return UUID.randomUUID().toString();
    }
    public void   setBe(String s) {}
PushResource.java

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/{randomSession}/")
@Singleton

public class PushResource {
    @PathParam("randomSession")
    private String randomSession;   
	
    @OnMessage(encoders = {JSONEncoder.class})
    public PushData onMessage(PushData pushData) {
        return pushData;
    }

    @OnMessage(encoders = {JSONEncoder.class})
    public Object onMessage(Object pushData) {
    	return pushData;
    }
    
    @OnOpen
    public void onOpen(RemoteEndpoint r, EventBus eventBus) {
    	if (randomSession == null)
    		System.out.println("<ERROR> Push connection not recognized, randomSession got <null>");
    	else
    		System.out.println("Push connection opened with randomSession " + randomSession);
    	
    }
    
    @OnClose
    public void onClose(RemoteEndpoint r, EventBus eventBus) {
    	if (randomSession == null)
    		System.out.println("Push connection with null randomSession closed");
    	else
    		System.out.println("Push connection closed with randomSession " + randomSession);
    }    
}

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

15 Aug 2014, 09:19

ok, thanks. Does it happen in other browsers to?

And yes, the change you made is indeed what I meant, but since what you describe happens explicitly in one browser, the change is superfluous. Well does randomSession become null to after some tries?

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

15 Aug 2014, 17:01

kukeltje wrote:ok, thanks. Does it happen in other browsers to?

And yes, the change you made is indeed what I meant, but since what you describe happens explicitly in one browser, the change is superfluous. Well does randomSession become null to after some tries?
Thanks again,

Yes,
randomSession becomes null once in a while, (even, sometimes, at first try).
no pattern predictable found,
even with another browser,

We have tested with IE too, and also sorting from Chrome to IE (ensuring different sessions in IE too).

Note that we are not much worried about randomSession getting null, but about that when this happens,
client DOES NOT receive push published messages!!.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 37 guests