Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Session timeout with Primefaces Portlets
I'm not sure if this an appropriate question for this group but I thought I'd give it a try and ask for forgivness later.
I having some user say they are getting prematurely logout even while they using my portal.
I'm not sure if this is a side affect of using Primefaces for my portlets that are based on ajax. I'm also using SennaJs as well.
I'm using the default 30 session timout. Here are the session related parameters I have setup in my portal-ext.properties file:
session.timeout.warning=0
session.timeout.auto.extend=false
session.timeout.redirect.on.expire=true
I'll admit this is one part of Liferay's properties that sometimes alludes me.
If anyone has any thoughts on this please share. It would be greatly appreciated.
I having some user say they are getting prematurely logout even while they using my portal.
I'm not sure if this is a side affect of using Primefaces for my portlets that are based on ajax. I'm also using SennaJs as well.
I'm using the default 30 session timout. Here are the session related parameters I have setup in my portal-ext.properties file:
session.timeout.warning=0
session.timeout.auto.extend=false
session.timeout.redirect.on.expire=true
I'll admit this is one part of Liferay's properties that sometimes alludes me.
If anyone has any thoughts on this please share. It would be greatly appreciated.
Faced a similar issue a long time back with Vaadin...
The app server and the browser will have some timeout assigned, say 30 minutes. Every normal portlet request resets the timer so things like the redirect on expire don't fire prematurely.
However, when you are doing pure AJAX calls, you are not resetting the timer at all. It will continue counting down in the browser, may continue counting down on the server.
When you are in this boat, you should periodically call Liferay.Session.extend() to reset the browser side and server side timers.
I will usually add this on every AJAX invocation, that way I don't have to figure out when "periodically" should occur.
The app server and the browser will have some timeout assigned, say 30 minutes. Every normal portlet request resets the timer so things like the redirect on expire don't fire prematurely.
However, when you are doing pure AJAX calls, you are not resetting the timer at all. It will continue counting down in the browser, may continue counting down on the server.
When you are in this boat, you should periodically call Liferay.Session.extend() to reset the browser side and server side timers.
I will usually add this on every AJAX invocation, that way I don't have to figure out when "periodically" should occur.
Kyle Joseph Stiemann, modified 6 Years ago.
Liferay Master
Posts: 760
Join Date: 1/14/13
Recent Posts
Thanks for reporting this William and for providing a fix David. This seems like it could be a nice feature for the Bridge so I've opened a ticket for it: FACES-3399.
- Kyle
- Kyle
Yes! That would be great Kyle. Doing some more searching it seems like this issue been around for a while.
I'll be testing this more today. I just updated more code where I thought it was most appropriate and tested it with no issues or side effects. I'll be turning those changes over to my key users for the further validation.
lol, I was sure it was the solution when I shared it...
ROTFL...
Actually there is a side effect...
Liferay.Session.extend() does invoke a backend call so the backend keeps the session live.
This turns each single AJAX call into a double call.
ROTFL...
Actually there is a side effect...
Liferay.Session.extend() does invoke a backend call so the backend keeps the session live.
This turns each single AJAX call into a double call.
Hmmm well I haven't commited this work yet. Are there any alternatives?
I just tested your claim about the double ajax call and I can't sustatiate it. I have the following ajax tag in one of my facelets:
<p:ajax event="rowSelect" oncomplete="Liferay.Session.extend();"
listener="#{docSetReviewView.onRowSelect}" update="@form" />
I added a log info message to my backend method, onRowSelect:
public void onRowSelect(SelectEvent event) {
LOGGER.info("----> In onRowSelect!!!!");
List<Doc> docs = docSet.getDocs();
int rownum = docs.indexOf((Doc) event.getObject());
docSet.getDocs().get(docIndex).setIndicator(null);
docIndex = rownum;
initCurrentDoc();
}
I only see one log message for every row selection which i made 7 of:
16:35:08,370 INFO [DocTypeClient:107] Property: DOC_TYPE_SERVICE_URI = http://localhost:9080n
16:35:14,154 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:16,829 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:19,130 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:22,073 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:26,041 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:28,214 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:41:59,313 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
Unless I'm not understanding the issue or that the Liferay.Session.extend(); is not really happening I can't confirm a double call.
Please let me know if there is anything else I should do to test or confirm this issue.
<p:ajax event="rowSelect" oncomplete="Liferay.Session.extend();"
listener="#{docSetReviewView.onRowSelect}" update="@form" />
I added a log info message to my backend method, onRowSelect:
public void onRowSelect(SelectEvent event) {
LOGGER.info("----> In onRowSelect!!!!");
List<Doc> docs = docSet.getDocs();
int rownum = docs.indexOf((Doc) event.getObject());
docSet.getDocs().get(docIndex).setIndicator(null);
docIndex = rownum;
initCurrentDoc();
}
I only see one log message for every row selection which i made 7 of:
16:35:08,370 INFO [DocTypeClient:107] Property: DOC_TYPE_SERVICE_URI = http://localhost:9080n
16:35:14,154 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:16,829 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:19,130 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:22,073 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:26,041 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:35:28,214 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
16:41:59,313 INFO [DocSetReviewView:560] ----> In onRowSelect!!!!
Unless I'm not understanding the issue or that the Liferay.Session.extend(); is not really happening I can't confirm a double call.
Please let me know if there is anything else I should do to test or confirm this issue.
Kyle Joseph Stiemann, modified 6 Years ago.
Liferay Master
Posts: 760
Join Date: 1/14/13
Recent Posts
Hi William, if Liferay.Session.extend() causes a second Ajax request, it would not necessarily duplicate the original JSF Ajax request. Instead it might send a special request to Liferay itself---bypassing your portlet entirely.I'd have to look into it further before I say for sure though. You can look at your browser console network logs to see what the request/response for Liferay.Session.extend() is. I doubt it would cause bugs, but it could affect performance.
Any chance you could look into this today? Again I'm not seeing anything bad that noticable but I loved to have your feedback as well? Thanks.
By the way I'm still on LR7 GA7
Kyle Joseph Stiemann, modified 6 Years ago.
Liferay Legend
Posts: 14933
Join Date: 9/2/06
Recent Posts
Sorry, guys, it doesn't duplicate your request, it is a different request...
It invokes /portal/extend_session which, in turn, will end up calling portal-web/docroot/html/portal/extend_session.jsp
So that is your second call.
It invokes /portal/extend_session which, in turn, will end up calling portal-web/docroot/html/portal/extend_session.jsp
So that is your second call.
So your saying its Ok? Its doing the right thing?
Sure, yes everything is absolutely fine.
I just wanted to point out the issue that you are adding a second AJAX request every time. It's important to know, some folks care about the number of generated requests.
I just wanted to point out the issue that you are adding a second AJAX request every time. It's important to know, some folks care about the number of generated requests.
Great! Thanks again for your input. Its always much appreciated.
Thanks David. This looks great!
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™