简体   繁体   English

Liferay Session mod_jk问题

[英]Liferay Session mod_jk issue

The session is not working with mod_jk load balancer (from httpd web server). 该会话不适用于mod_jk负载平衡器(来自httpd Web服务器)。 However, the same code is working fine in the application server. 但是,相同的代码在应用程序服务器中运行正常。

Following is worker.properties: 以下是worker.properties:

worker.list=loadbalancer,status,web

worker.node0.port=8009
worker.node0.host=10.50.26.19
worker.node0.type=ajp13
worker.node0.lbfactor=1
worker.node0.socket_keepalive=false

worker.node0.connect_timeout=10000
worker.node0.prepost_timeout=10000
worker.node0.socket_timeout=60

worker.node0.connection_pool_timeout=600

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node0
worker.loadbalancer.sticky_session=1

Java Code in Portlet 1: Portlet 1中的Java代码:

PortletSession portletSession = actionRequest.getPortletSession();
portletSession.setAttribute("username",reg.getFname(), PortletSession.APPLICATION_SCOPE);

JSP Code in Portlet 2: Portlet 2中的JSP代码:

PortletSession portletSessionobject = renderRequest.getPortletSession();
userName=(String)portletSessionobject.getAttribute("username",PortletSession.APPLICATION_SCOPE);

In both the portlet the following property have been applied in the liferay-portlet.xml 在两个portlet中,以下属性已在liferay-portlet.xml中应用

<private-session-attributes>false</private-session-attributes>

But unable to get username in the Portlet 2 JSP page in web server it is returning null. 但是无法在Web服务器的Portlet 2 JSP页面中获取用户名,它返回null。 But in the application server the value is coming as expected. 但是在应用程序服务器中,该值如预期般来了。 Please suggest. 请提出建议。

After doing much research found the solution. 经过大量研究,找到了解决方案。 Hence posting it to help others. 因此发布它以帮助他人。 There are two things that cause the issue. 造成此问题的原因有两点。

i) The sessions were overwritten by the httpd server. i)会话被httpd服务器覆盖。 Following header tag was added in the httpd.conf which actually caused the issue. 在httpd.conf中添加了以下标头标记,这实际上是导致该问题的原因。 Removed it and JSESSION started to appear. 删除它,JSESSION开始出现。

Header set Set-Cookie HttpOnly;Secure

ii) Session Affinity was not working properly due to jvmRoute was not defined. ii)由于未定义jvmRoute,因此会话关联性无法正常工作。 As a result, the session gets terminated intermittently. 结果,会话间歇性地终止。 So added the instance-id for subsystem web in the standalone.xml of each instance, 因此,在每个实例的standalone.xml中添加了子系统Web的实例ID,

For node0, 对于node0,

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="node0" native="false">

For node1, 对于node1,

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="node1" native="false">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM