logo       

Re: Resin 3.0.6 TCP Sessions Problem Please Advise: msg#00023

text.xml.resin.user

Subject: Re: Resin 3.0.6 TCP Sessions Problem Please Advise

Chris Wilson wrote:

Hello,

I continue to have problems getting distributed sessions to work in
Resin 3.0.6 where they worked perfectly on Resin 2.x.

You can try the snaphot or set an explicit <host id="localhost"/>. Resin 3.0.6 is treating the two requests as two different virtual hosts: localhost:8080 and localhost:8081 and therefore not sharing. (The virtual host issue is only for the purposes of the distributed sessions. The other virtual hosting is fine.)

- Scott

I have created a minimal test application to attempt to get session
replication at least working on the *same machine*!

I am attempting to run two instances of Resin on the same machine at
different ports (http 8080 & 8081). I have disabled session cookies and
am using URL encoding so that I can easily switch between server
instances by merely changing the port in address bar. Since the session
id is in the URL and if distributed sessions are working properly I
should see the exact same session contents on both servers as I switch
between servers.

The sequence I follow is this.

1) Start server a
2) Start server b
3) Access server a at: http://localhost:8080/cluster/index.jsp
4) Put a few values in the session using the JSP
5) Since URL encoding is on, URL ends up being something like:
http://localhost:8080/cluster/index.jsp;jsessionid=afHdQ3T1wHIf
6) Change port to 8081 in address bar to access server b; leave the rest
of the URL the same, hit enter.

I should see the same session information on server b since the session
id is the same, however, the session data is empty.

If I try the reverse--accessing server b first with a fresh session and
then moving to server a--the same thing happens. Order doesn't seem to
be an issue...

What am I doing wrong here?
I have the following resin.conf

--------------------------------------------------------

<resin xmlns="http://caucho.com/ns/resin";>
<log name='com.caucho.server.cluster' level='all' path='stdout:'
timestamp='[%H:%M:%S.%s] '/>
<log name='com.caucho.server.session' level='all' path='stdout:'
timestamp='[%H:%M:%S.%s] '/>
<log name='com.caucho.server.hmux.HmuxClusterRequest' level='all'
path='stdout:' timestamp='[%H:%M:%S.%s] '/>
<log name='com.caucho.server.hmux.HmuxDispatchRequest' level='all'
path='stdout:' timestamp='[%H:%M:%S.%s] '/>
<log name='' level='info' path='stdout:' timestamp='[%H:%M:%S.%s] '/>
<log name='com.caucho.java' level='fine' path='stdout:'
timestamp='[%H:%M:%S.%s] '/>
<log name='com.caucho.loader' level='config' path='stdout:'
timestamp='[%H:%M:%S.%s] '/>

<dependency-check-interval>2s</dependency-check-interval>

<javac compiler="internal" args=""/>

<thread-pool>
<thread-max>200</thread-max>
<spare-thread-min>25</spare-thread-min>
</thread-pool>

<server>
<class-loader>
<tree-loader path="$resin-home/lib"/>
</class-loader>

<!-- The http port -->
<http id="a" host="127.0.0.1" port="8080"/>
<http id="b" host="127.0.0.1" port="8081"/>

<cluster>
<srun id="a" host="127.0.0.1" port="6802" index="1"/>
<srun id="b" host="127.0.0.1" port="6803" index="2"/>
<cluster-store type="tcp">
<init>
<!-- store seessions for each server instance in a different
directory since both instances are running on the same
machine
and we dont want persistent storage to collide -->
<path>${serverId}-sessions</path>
</init>
</cluster-store>
</cluster>

<ignore-client-disconnect>true</ignore-client-disconnect>
<case-insensitive>false</case-insensitive>

<resin:include path="app-default.xml"/>

<host id="">
<web-app id="/cluster">
<document-directory>webapps/cluster</document-directory>
<session-config
enable-cookies="false"
enable-url-rewriting="true">
<cluster-store/>
</session-config>
<context-param server-id="${serverId}"/>
</web-app>
</host>
</server>
</resin>

------------------------------------------------------

webapps/cluster/index.jsp

------------------------------------------------------

<%@ page import="java.util.*" %>
<%
boolean isSubmit = request.getParameter("submit") != null;
String newKey = request.getParameter("key");
String newValue = request.getParameter("value");
if(isSubmit && newKey.trim().length() > 0) {
session.setAttribute(newKey, newValue);
}

String deleteKey = request.getParameter("delete");
if(deleteKey != null) {
session.removeAttribute(deleteKey);
}

if(request.getParameter("invalidate") != null) {
session.invalidate();

response.sendRedirect(response.encodeRedirectURL("index.jsp"));
}
%>
<html>
<head>
<title>Session Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>Current Session:</p>
<p>
<%
Enumeration e = session.getAttributeNames();
while(e.hasMoreElements()) {
String key = (String)e.nextElement();
String value = (String)session.getAttribute(key);
%>
<%= key %>: <%= value %> <a href="<%=
response.encodeURL("index.jsp?delete=" + key) %>">[delete]</a><br>
<% } %>
</p>
<form name="form" method="post" action="<%=
response.encodeURL("index.jsp") %>">
<p>Key: <input name="key" type="text" id="key">
<br>
Value: <input name="value" type="text" id="value">
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
<p>
<a href="<%= response.encodeURL("index.jsp?invalidate=x")
%>">Invalidate</a>
</p>
<p><a href="<%= response.encodeURL("index.jsp") %>">Reload</a> </p>
<p>Server ID: <%= application.getInitParameter("server-id") %></p>
</body>
</html>

----------------------------------------------

Environment:

Sun JDK 1.4.2
Windows XP
Resin 3.0.6

Could someone please try this and see if they can either get it to work
or duplicate my failure? Up to this point I have been unable to get
Resin 3.0.6 to correctly cluster using any configuration. This is the
simplest clustering setup I could come up with. If this setup does not
cluster as configured, why? What is wrong? Shouldn't this *at least*
work?

Thanks for any help.

Chris Wilson

Web Developer
Andrews University
cwilson@xxxxxxxxxxx
http://www.andrews.edu/~cwilson/pgp/







<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise