Forum Discussion

KJ_50941's avatar
KJ_50941
Icon for Nimbostratus rankNimbostratus
Sep 22, 2015

irule for 503 error if all pool memebers are down

I have a requirement to display page from F5 with 503 error once all pool members are down. I got below iRule from Dev central but I getting syntax error , what I am doing wrong.?

 

if { [active_members My_DEV_443_Pool ] < 1 } { HTTP::respond 503 content "503 Service UnavailablePage is currently unavailable.The system is unable to fulfill your request. This is not a problem with your computer or network connection.:

 

\ " event disable TCP::close } }

 

will this work?

 

Thx

 

12 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    KJ

    You've got some basic syntax errors and you're missing the Event HTTP_REQUEST. Now as for your use of TCP close and Event Disable i'm not 100% on whether they can work together. Need to test that. Anyway something like this?

     

    when HTTP_REQUEST
     if { [active_members My_DEV_443_Pool] < 1 } { 
         HTTP::respond 503 content "Page is currently unavailable.The system is unable to fulfill your request. This is not a problem with your computer or network connection.:\" 
         event disable 
         TCP::close 
         }
    

     

  • sorry it was typo on my part I had when HTTP_REQUEST , however I am still receiving syntax error, I removed "event disable and TCP:close , still no joy.

     

    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      Oops. Typo on my part too. You'll need a curly brace after HTTP_REQUEST { and then a closed curly brace at the end too.
  • I will add a few comments about the 'event disable' and 'TCP::close' functions. I've not seen many developers use them at all, but they are really nice functions to give a final polish to your code.

    The event disable command is optional if it's your only iRule, however, if you use more iRules that imply other HTTP redirects or respond messages, it's a must-have command to prevent TCL errors (multiple redirect/respond invocations violation).

    In regards to TCP::close, it's optional, but recommended since the Web Browser of a client and F5 (clientside listener) can keep the TCP connection open for quite a while if there's no "Connection=Close" header specified. That means, any other iRule code that were processed before the "Error 503" iRule, will not work once the clients try to re-visit the URL that triggered the 503 response in the first place. That happens because according to F5 those blocks of code were already processed, and it can keep causing problems until client finally attempts to connect from a new Web Browser window, or until you forcefully kill the clientside TCP connection in F5!

    To conclude, you can and should use both of them together when working with multiple redirect/respond iRules for HTTP services.

  • How can I change the font for this ?for example "Page is currently unavailable. The system is unable to fulfill your request. This is not a problem with your computer or network connection.

     

    currently it displays very plain.

     

    Thank you again.

     

  • will that work? The system is unable to fulfill your request. This is not a problem with your computer or network connection
  • I resolve this by using ifile and I rule works great.

     

    Thx

     

    All

     

  • I resolve this by using ifile and I rule works great.

     

    Thx

     

    All