Forum Discussion
Irwin_Fletcher_
Nimbostratus
Jul 26, 2007URI Session ID based persistence issue
I’ve come across a need for persistence based off a session ID imbedded in a URI, and unfortunately, I can not get it to work.
Here’s the lowdown – I need to persist users based upon a sessi...
Deb_Allen_18
Aug 06, 2007Historic F5 Account
The code above needed a couple of corrections.
If there was no match on the findstr command, the value for $fletchpersist == null and "session add" throws a runtime error "wrong args" because no value was specified for the "key" parameter. Fixed by making execution of "session add" command dependent on non-null value for key.
Once that was fixed, I started getting the dreaded "prerequisite operation not in progress" when trying to add a session table entry after the node was directly selected. Session commands don't seem to have the right context after direct node selection, instead generating that error. Fixed by making execution of "session add" command further dependent on absence of value for $server (value only exists if node was directly selected.) Also re-added existing session table entry in HTTP_REQUEST to update persistence timeout, preventing persistence from timing out.
when RULE_INIT {
set ::fletchtimeout 600
}
when HTTP_REQUEST {
set fletchpersist [findstr [HTTP::uri] "(X(1)S(" 7 ")"]
log local0. "fletchpersistvalue is >$fletchpersist<"
if {$fletchpersist != "" }{
set server [session lookup uie $fletchpersist]
if {$server != "" }{
directly select the desired server as stored in the session table
re-add to session table to update timeout
(session table update in LB_SELECTED n/a for direct node selection)
session add uie $fletchpersist $server $::fletchtimeout
node [getfield $server : 1] [getfield $server : 2]
log local0. "fletchpersist: $fletchpersist server found: $server"
}
} else {
log local0. "No fletchpersist value found. Load balancing connection."
pool ryan_mobiletest_0
}
}
when LB_SELECTED {
add server info to session table when server selected
only add if key exists & node not directly selected above
if {$fletchpersist != "" && $server ==""}{
session add uie $fletchpersist [LB::server addr]:[LB::server port] $::fletchtimeout
log local0. "fletchpersist: $fletchpersist server: [session lookup uie $fletchpersist]"
}
}
when LB_FAILED {
detach and choose a new server if the selected server fails to respond.
new session entry will be written in LB_SELECTED on each attempt
LB::detach
LB::reselect
}Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
