Forum Discussion
Sahir_180434
Nimbostratus
Jan 21, 2016Need help with iRule error log message
Hi all, I am working on upgrading an ltm from 10.2.4 to 11.5.3, all iRules on current 10.2.4 code are working fine but when did the upgrade I got the following error on one of the iRules: Jan...
Kai_Wilke
MVP
Jan 27, 2016Hi Sahir,
the problem can be found in this code block...
if { [findstr [HTTP::uri] "jsessionid" 11 "!"] != ""} {
pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]
log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
} else {
pool ets_80-pool
log local0. "No jsession ID, local balancing the connection..."
}
If the client sends an [HTTP::uri] containing the string jsessionid, you'll will use a substring of it to find an matching [session lookup uie] record. But then you don't verify if the session query has deliverd any values before proceeding with the member node selection. I highly doubt this code has ever worked stable...?
An improved code would look like this...
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSESSIONID"] } {
set trimID [lindex [split [HTTP::cookie "JSESSIONID"] "!" ] 0 ]
if { [session lookup uie $trimID] equals "" } {
session add uie $trimID [IP::server_addr] 1800
log local0. "added server entry [session lookup uie $trimID] for jsessionID $trimID "
} else {
log local0. "existing server entry [session lookup uie $trimID] for jsessionID $trimID"
}
}
}
when HTTP_REQUEST {
if { [active_members et-pool] == 0 } {
HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/unavailable/etServices.html"
} else {
if { [HTTP::header exists "X-Forwarded-Host"] } {
HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
}
if { [HTTP::cookie exists "em-et"] } {
log local0. "Persisting by cookie em-et, contents are [HTTP::cookie "em-et"]"
} else {
set pool_member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"]]
if { $pool_member ne "" } {
pool ets_80-pool member $pool_member
log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
} else {
pool ets_80-pool
log local0. "No jsession ID, local balancing the connection..."
}
}
}
}
Note: You may apply the improved code before updating the device...
Cheers, Kai
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