Forum Discussion

Julian_Annison_'s avatar
Julian_Annison_
Icon for Nimbostratus rankNimbostratus
Jun 21, 2005

Cookie persistence with URI over ride

The rule is intended to persist on a cookie called JSESSIONID except if the uri contains jsessionid, it then uses the findstr command to pass out the jsessionid i.e. J2EE806189900 it the maps the to class WD_members and sends it directly to the pool member.

The persistence appears to work until the direct call to the pool member is made and the persistence is broken. I am not sure if when the persistence is over ridden it corrupts or breaks the persistence record or if it is just the way the rule is written. I put this rule together from various posts on this forum.

On the Virtual server i only have the iRule applied, do i have to also add simple persistence as well and also how can you change the timeout value if you are persisting via an irule?

Thanks

Julian

 
 class WD_members  { 
    "J2EE806189900 10.235.69.155:58000" 
    "J2EE806190000 10.235.69.154:58000" 
    "J2EE809133200 10.235.69.153:58000" 
 } 
   
 rule sap_version9 { 
    when CLIENT_ACCEPTED { 
       set add_persist 1 
    } 
    when HTTP_RESPONSE { 
       if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } { 
          persist add uie [HTTP::cookie "JSESSIONID"] 
          log local0. "HTTP response SAPCookie [HTTP::cookie JSESSIONID]" 
          set add_persist 0 
       } 
    }   
    when HTTP_REQUEST { 
        Note the cookie is JSESSIONID 
       log local0. "HTTP URL [HTTP::uri]" 
       log local0. "HTTP request SAPCookie [HTTP::cookie JSESSIONID]" 
       set jsess [findstr [HTTP::uri] "jsessionid" 12 ")"] 
       if { [HTTP::cookie exists "JSESSIONID"] and $jsess eq "" } { 
          log local0. "No jeesssionid in URI persisting on cookie[HTTP::cookie JSESSIONID]" 
          persist uie [HTTP::cookie "JSESSIONID"] } { 
  
        Cookie not present, select member based on uri 
       if { [HTTP::uri] contains "jsessionid" } {   
          set node [findclass $jsess $::WD_members " "] 
          pool wdsapphire_pool member $node 
          log local0. "sending request to $node" 
       } 
    } 
 } 
 } 
 
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Based on this more complete information, I would have update the rule:

     
     class WD_members { 
        "J2EE806189900 10.235.69.155:58000" 
        "J2EE806190000 10.235.69.154:58000" 
        "J2EE809133200 10.235.69.153:58000" 
     } 
      
     rule sap_version9 { 
        when CLIENT_ACCEPTED { 
           set add_persist 1 
        } 
        when HTTP_RESPONSE { 
           if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } { 
              persist add uie $jsess 
              log local0. "HTTP response SAPCookie [HTTP::cookie JSESSIONID]" 
              set add_persist 0 
           } 
        } 
        when HTTP_REQUEST { 
            Note the cookie is JSESSIONID 
           log local0. "HTTP URL [HTTP::uri]" 
           log local0. "HTTP request SAPCookie [HTTP::cookie JSESSIONID]" 
           set jsess [findstr [HTTP::uri] "jsessionid" 12 ")"] 
           if { $jsess eq "" } { 
              log local0. "No jsessionid in URI, using cookie" 
              if { [HTTP::cookie exists "JSESSIONID"] } { 
                 persist uie [HTTP::cookie "JSESSIONID"] 
              } 
           } else { 
              log local0. "Found jsessionid in URI: $jsess" 
              set node [findclass $jsess $::WD_members " "] 
              if { $node ne "" } { 
                 log local0. "Sending request to $node" 
                 pool wdsapphire_pool member $node 
              } else { 
                 log local0. "Unknown J2EE key: $jsess" 
              } 
           } 
        } 
     }