MaheshV_65076
May 22, 2008Nimbostratus
jsessionid persistence
We recently started to use F5 8800 & 6800 in our environment. But we aren’t able to make sticky sessions work.
I browsed through the dev central and found couple of solutions (
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=60848691
http://devcentral.f5.com/default.aspx?tabid=53&view=topic&forumid=5&postid=8098 ) but it isn’t working or robust enough. For instance
a)how to delete entries from persistence hash
b)if browser is not closed for a long time and it sends an old stale jsessionid, this iRule should forward the request to the virtual server rather than rejecting the request.
In the following Universal persistence rule should we use set SessionId [findstr [[HTTP::header] Set-Cookie] "JSessionId" 11] ?
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSESSIONID"] } {
set trimID [lindex [split [HTTP::cookie "JSESSIONID"] "!" ] 0]
if { [persist lookup uie $trimID] equals "" } {
persist add uie $trimID 1800
log "added persistent entry $trimID for server [LB::server addr]"
} else { log "continued sessionID $trimID for server [LB::server addr]" }
}
}
when HTTP_REQUEST {
if { [active_members MyPool] == 0 } {
HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/myUri.html"
}
if { [HTTP::header exists "X-Forwarded-Host"] } {
HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
}
if { not [HTTP::cookie exists "MyCookie"] } {
set jsess [findstr [HTTP::uri] "jsessionid" 11 "!"]
if { $jsess != "" } {
persist uie $jsess 1800
log "Used URI, value is $jsess, server [LB::server addr]"
}
} else {
log "used Cookie Insert, value is [HTTP::cookie "MyCookie"]"
}
}
Jsessionid is session cookie which does not have time stamp when it is received by F5 from the server.
In the above iRule, when a http request is received the F5 will route the request to the original physical node where the jsessionid was created?
Now how do I flush the persistence hash in F5?
You may be aware that jsessionid cookie is created by a Java Application server. The server also determines when the cookie is stale and generates a new session cookie. Since this is a session (inline) cookie, cookie expiration is not set. This is a standard Java implementation.
As a result both the browser and the F5 do not have the logic to determine when the jsessionid cookie has expired. This is particularly a problem where there is no explicit “user logout” call from the browser.
One more point is, that jsessionid expiration is an idle timeout value. This means it is renewed on the server side with every request.
Is there a more robust iRule to make the sticky session work?
Appreciate your help.