Forum Discussion

Eric_Renner's avatar
Eric_Renner
Icon for Nimbostratus rankNimbostratus
Oct 18, 2019

Persistence based on id within XML file

Hello,

I'm trying to build an iRule which is doing universal persistence based on a string within the POST request of an xml file. This xml file contains the string <chatId>xxxxxxxxxxxxxxxx</chatId>. I want to parse the string between <chatId> and </chatId> to use it for persistence. This is necessary because cookie or source address persistence is not working as all requests comes from a single proxy IP and the clients are not supporting cookies. The http header also doesn't contains any data which can be used for persistence.

To get this work I've written the following rule:

when HTTP_REQUEST {

   if { (([HTTP::method] equals "POST") and ([HTTP::uri] contains "/chatSession")) } {

       HTTP::collect

       log local0. "Parsed payload: [HTTP::payload]"

   }

}

when HTTP_REQUEST_DATA {

      set SESSIONID [findstr [HTTP::payload] "chatId" 1 16]

      log local0. "Parsed chatId: $SESSIONID"

      persist uie $SESSIONID 120

       HTTP::release

}

I've added some log statements to see what is parsed from the request but unforetunately always an empty string is returned in the logfile and the client gets a timeout while trying to access the VIP.

Hope you can help me to get this solved

Many thanks in advance

 

2 Replies

  • As a general check, I would recommend using OneConnect with /32 netmask when using L7 persistence. May be limit the data that is collected using HTTP::collect ? As a sanity check, can you verify and make sure you the case (upper/lower) is correct in the iRule when parsing data ?

     

     

    • Anirban's avatar
      Anirban
      Icon for Nimbostratus rankNimbostratus

      I am new to iRules.

      Http request is creating client side persistence. Dont we require http_response rule and persist add uie to maintain server side persistence.

       

      Just a general question.