cancel
Showing results for 
Search instead for 
Did you mean: 

Session Timeout using jsession iRule

Toby_Penn_11283
Nimbostratus
Nimbostratus
I'm using the following iRule to load balance and track my sessions (funky app, don't ask):

 

 

when CLIENT_ACCEPTED {

 

set add_persist 1

 

}

 

when HTTP_RESPONSE {

 

if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {

 

persist add uie [HTTP::cookie "JSESSIONID"]

 

set add_persist 0

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "JSESSIONID"] } {

 

persist uie [HTTP::cookie "JSESSIONID"]

 

} else {

 

set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]

 

if { $jsess != "" } {

 

persist uie $jsess

 

}

 

}

 

}

 

 

I need to extend the session timeout period beyond 5 minutes. Modifying the protocol profile does not seem to do the trick. I don't see anything in here that would indicate that there is a variable that I can tweak to get a longer session timeout. Anyone have any ideas??
6 REPLIES 6

JRahm
Community Manager
Community Manager
What specifically is timing out? The app? TCP? The persistence setting? Idletimeout on the tcp profile will fix tcp timeouts. adding a value in seconds after the persist command will lengthen the persist timeout:

 

 

persist add uie [HTTP::cookie "JSESSIONID"] 1800

 

 

Are you having success with persisting on the whole cookie? I was getting irregularities with the server garbage after the jsessionid string, so I am only using the id:

 

 

[lindex [split [HTTP::cookie "JSESSIONID"] "!" ] 0]

 

 

I thought string trimright would have been easier, but it wasn't working as I had hoped.

Toby_Penn_11283
Nimbostratus
Nimbostratus
I'll try adding the 1800 at the end of the persist command. See how that works out. Thanks.

Deb_Allen_18
Historic F5 Account
Alternatively, you can apply the rule via a peristence profile of type uie and set the timeout value there. That allows you to change the timeout without having to edit the rule itself -- comes in handy if you want to use the same rule for different apps with different timeout requirements.

 

 

/deb

Elias_O_16228
Nimbostratus
Nimbostratus

I know this is an old thread. Here is my scenario: Two webservers running Java applications. The servers have 1hr timeout keepalive set. We noticed that some customers IP changes with same JSESSIONID, maybe due to proxy. In other words, two IP addresses with one JSESSIONID. I'm not familiar that how one tcp request could have more than one IP address. But to cut the long story short, it's happening. We are seering same JSESSIONID in both servers with different IP addresses.

 

For example: JSESSIONID23456 with IP address 192.159.9.9 server 01 JSESSIONID23456 with IP address 192.159.10.10 server 02

 

This causes timeout.

 

We implemented Source address Affirnity, that did not work. We implemented universal persistence with source-add as fallback, that did not seem to work either.

 

I need help for irule that will persist to one server based on JSESSIONID.

 

Below is irule tested but it did not work; when HTTP_RESPONSE { if { [HTTP::cookie exists "JSESSIONID"] } { persist add uie [HTTP::cookie "JSESSIONID"] } } when HTTP_REQUEST { if { [HTTP::cookie exists "JSESSIONID"] } { persist uie [HTTP::cookie "JSESSIONID"] } }

are you using oneconnect profile? if not, can you try? sol7964: Persistence may fail for subsequent requests on Keep-Alive connections https://support.f5.com/kb/en-us/solutions/public/7000/900/sol7964.html