Forum Discussion

Rob_Wal's avatar
Rob_Wal
Icon for Nimbostratus rankNimbostratus
Sep 26, 2014

Send Post/GET to all nodes regarless of status

I am trying to send a POST or a GET to all nodes in a pool regardless of the node status.

 

I pieced together the following code. The issue is that the website is not ready yet so I am working with 404 and checking IIS logs. We want the request to be sent to each node once regardless of the return code. Then we want to display a page to the user with some status.

 

I use curl to send data it post to each node. But I get "curl: (56) Recv failure: Connection reset by peer"

 

If I visit the page in a browser (GET) it sends 250 request to each node.

 

works but creates a 250 request when page is visited in browser
send 1 POST to each node if curl is used to post data
curl --data "cacheclear=1" http://site.robert.com/clear

when HTTP_REQUEST {
set variables
set pool [LB::server pool]
set memberslist {}
set members [members -list [LB::server pool]]
set posturl "http://[HTTP::host][HTTP::uri]"
 save original request
set req [HTTP::request]
set reqcount to the total number of servers in assigned pool
set reqcount [active_members [LB::server pool]]

look for the trigger in the URL/URi
    if { [string tolower [HTTP::uri]] eq "/clear" } {

send request to the vip default pool
pool $pool 

}
 }        
http retry only works in http_response
when HTTP_RESPONSE {
since no test page existing working with 404 status. we can change this later and add error checking
if { [HTTP::status] equals 404 } {
         if request count is greater than 0, decrement variable and retry request
        if { $reqcount > 0 } {
            incr reqcount -1
            HTTP::retry $req
}
respond to user
set response "URL: $posturl 
  Pool: $pool 
 Members List: $memberslist 
 Current Member: [LB::server addr]  
 Reguest Info: $req 
 Active Members:" 
HTTP::respond 200 content $response "Content-Type" "text/html" 
}
}

2 Replies

  • the site honored the code in the response section. I am not sure how to fix it. ~~~ please ignore the html response set response "URL: $posturl

     

    Pool: $pool

     

    Members List: $memberslist

     

    Current Member: [LB::server addr]

     

    Reguest Info: $req

     

     

    Active Members:" ~~~
  • bump.

     

    I have tried HSL but there is no example of sending to multiple nodes in a single pool. Examples are alternate pool or sending to multiple pools.