Forum Discussion

Rupa_34586's avatar
Rupa_34586
Icon for Nimbostratus rankNimbostratus
Dec 31, 2009

irule is taking wrong cookie

I am using the below irule for cookie based routing.

 

The irule is not taking the cookie value properly.I am observing cookies on my browser using HTTP Watch pro.

 

I see JTAP=POD25 in httpwatch pro and in Irule logs i see JTAP=POD2. I am not sure from where the irule is taking the value POD2. Could somebody please tell wheres wrong

 

 

if { [HTTP::cookie "JTAP"] ne "" } {

 

log local0. " Web tier: *** Found JTAP Cookie: [HTTP::cookie JTAP]"

 

set JTAP [string tolower [getfield [HTTP::cookie "JTAP"] "^" 3]]

 

pool p_$JTAP

 

log local0. "Web tier: *** Request went to $JTAP"

 

}

 

else {

 

pool p_default

 

}

 

 

Thanks for your help and have a Happy New Year

6 Replies

  • Hi Rupa,

     

    Looking at your irule it appears that there are several items in JTAP? Something like "JTAP=value^value2^value3" and you are trying to extra the 3rd field? Just need to understand why you needed the getfield

     

     

    Bhattman
  • Hi Bhattman,

     

     

    Sorry my bad,

     

     

    My cookie JTAP looks like pay^app^pod25. i am retriving the 3rd value from that.Because i named the pool with the 3rd value.

     

     

    if you see the first log statement in my irule

     

    log local0. " Web tier: *** Found JTAP Cookie: [HTTP::cookie JTAP]"

     

     

    I am logging the JTAP value. I am getting pay^app^pod2 in the logs.But in HTTP watch pro i see JTAP=pay^app^pod25

     

     

    what could be the problem?

     

     

    Regards,

     

    Rupa
  • Hi Rupa,

    The iRule looks straightforward enough. Can you post a sample from the ltm log for a failure?

    Here is a quick test showing the parsing working correctly:

     
     when RULE_INIT { 
      
        set cookie "abc^def^ghi" 
        log local0. " \$cookie: $cookie; \[getfield $cookie \"^\" 3\]: [getfield $cookie "^" 3]" 
     } 
     

    And the ltm log output:

    Rule : $cookie: abc^def^ghi; [getfield abc^def^ghi "^" 3]: ghi

    Thanks,

    Aaron
  • Hi Rupa,

     

     

    I was asking if you could post the log output from these two log lines:

     

     

    log local0. "Web tier: *** Found JTAP Cookie: [HTTP::cookie JTAP]"

     

    log local0. "Web tier: *** Request went to $JTAP"

     

     

    Also, can you clarify which host you captured the tcpdump. If it was on LTM, was it on the client or server VLAN?

     

     

    Thanks,

     

    Aaron
  • thanks for your reply,

     

     

    there is no issue with F5.My webserver is truncating the cookie.
  • Glad you figured out the problem. Thanks for clarifying it.

     

     

    Aaron