Weblogic JSESSIONID Persistence BIG-IP v4

Problem this snippet solves:

This BIG-IP v4.x iRule provides persistence on the JSessionID value found in either the URI or a cookie for WebLogic servers. This solution was tested on WebLogic v7.x and BIG-IP v4.5.13. Be forewarned that other versions of WebLogic may use a different cookie format than the one expected by this iRule.

How to use this snippet:

Building the configuration

Build the class mapping first. The jsessionid string contains a consistent hash of the server IP address which will not change unless the server is re-addressed. (This ID value is not guaranteed to persist through WL upgrades.) Determine the hash value for each server by observing the jsessionid strings generated by the server and extracting the entire field between the the 2nd and 3rd "!" character:

For instance, server 1 generates a jsessionid parameter that looks like this: jsessionid=l0ngr4ndom$3qu3nc3ofch4r4ct3rs!-123456789!-987654321!8082!8081

Extract the server hash (-987654321) and use it to create the class mapping to the appropriate server definition: "-98765432110.0.0.101:8081"

Next create the appropriate pools, applying the indicated select statements.

Then build the iRule and apply to the WebLogic virtual server definition.


First we use UIE expressions to extract server-referencing string, then use extracted values to identify target node:

URI parse (assumes jsessionid will always be the first parameter in URI): getfield(getfield(http_uri, ';', 2), '!', 3)

cookie parse: getfield(http_cookie("jsessionid"), '!', 3)

Map extracted value to target node: mapclass2node( ), WLnodes) mapclass2node( ), WLnodes)

Resulting node selection expressions -- cookie-enabled traffic & non-cookie-enabled traffic: mapclass2node(getfield(getfield(http_uri, ';', 2), '!', 3), WLnodes) mapclass2node(getfield(http_cookie("jsessionid"), '!', 3), WLnodes)

(The select statement assumes jsessionid will always be the first parameter in URI. If that is not the case, additional string manipulation may be necessary to extract the jsessionid parameter first.)

Code :

# Class

class WLnodes {

# Pools with select statements

pool WL-persistCookie {
   lb_method observed
   select mapclass2node(getfield(http_cookie("jsessionid"), '!', 3), WLnodes)

pool WL-persistURI {
   lb_method observed
   select mapclass2node(getfield(getfield(http_uri, ';', 2), '!', 3), WLnodes)

# iRule Source

rule WL-persist {
   if (http_uri contains "jsessionid=") {
      use pool WL-persistURI
   else {
      use pool WL-persistCookie
Published Mar 18, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment