Forum Discussion

JPV_131616's avatar
Oct 03, 2013

persisting different clients to same server based on where the process is started

Hi,

 

I have a requirement to persist a client to a server where the app process starts (POSTs a soap call), this is fine, but then an ID is passed to a different app/client which does a GET, which also needs to be persisted to where the app process started.

 

Any idea how to do this?

 

thx

 

3 Replies

  • Can you clarify who the clients and who the servers are? You say "different clients", so assuming you mean that a downstream service (client) makes a call to the same VIP and must be persisted to the same server that the original client was sent to. Is that correct?

     

  • the clients are two different applications. They call the same VIP but using different methods.

     

    1. first client posts a SOAP message to the app servers behind the vip, when this happens, it creates a caseId, which it then passes to another application in next flow. This caseId will be used to continue the processing, which means any further communication using this caseId needs to go to the first server where it was created via Soap Call - as this info isn't shared to the servers behind f5.

       

    2. Later in the flow another application (different client app/server) will call this VIP again but using a GET, passing caseId in the URI being called - this GET needs to go to the server where the caseID was created otherwise the server won't know what it is..

       

    the caseId when created is only available in HTTP_RESPONSE data - this I've been able to grab and set into a variable in the irule.

     

    thanks

     

  • This may not even be remotely what you're looking for, but take a look at this:

    when HTTP_REQUEST {
        log local0. "requesting [HTTP::uri]"
        if { ( [HTTP::method] equals "POST" ) and ( [string tolower [HTTP::uri]] equals "/soapcall.php" ) } {
            set catch_clientid 1
        } elseif { [string tolower [HTTP::uri]] starts_with "/secondrequest" } {
            set clientid [URI::query [HTTP::uri] clientid]
            set persistTo [session lookup uie $clientid]
            log local0. "persisting to $persistTo"
            pool [LB::server pool] member $persistTo
        }
    }
    when HTTP_RESPONSE {
        if { [info exists catch_clientid] } {
            unset catch_clientid
            set clientid [URI::query "?[HTTP::header Location]" clientid]
            log local0. "setting persistence for $clientid to server [LB::server addr]"
            session add uie $clientid [LB::server addr]
        }
    }
    

    I also didn't have your environment to work with, so I generated a simple web page that immediately redirected me to another with a query string (ex. ?clientid=1234567890). I post to the first page (/soapcall.php), which sets a flag variable. On response from the soapcall page, the HTTP_RESPONSE event grabs the clientid (mine is in the Location header but yours could be somewhere in the payload), creates a session entry based on the clientid, and stores the selected LB server. When the client makes a subsequent GET request with the clientid query string, I look up the LB server data from the session table and pool to that member. This of course works as long as the client is sending the clientid in the query string.