Forum Discussion

cralston_17844's avatar
cralston_17844
Icon for Nimbostratus rankNimbostratus
Jan 20, 2010

TCL error while executing "HTTP::method"

I've been trying to clean up my /var/log/ltm errors lately, at the suggestion of F5 support. One that's been bugging me is this:

 

 

tmm tmm[1208]: 01220001:3: TCL error: IRULE_foobar - while executing "HTTP::method"

 

 

I get about a thousand of those entries a day out of hundreds of thousands of executions of the iRule.

 

 

My gut feeling is that it's an ignorable error that is generated when an HTTP request aborts or times out before the iRule runs (or finishes running), such that HTTP::method is sort of a limbo call to make.

 

 

On the other hand, I don't get any errors for any other iRules that include HTTP::method in them, even though they're not being used as frequently.

 

 

The rule in question appends a local X- header for most traffic giving some info about what sort of forwarding took place, original client IP, SSL status, etc. The sites we host use this data in varying amounts.

 

 

Here's the key part of the code:

 

 
 when HTTP_REQUEST { 
     if { [HTTP::method] equals "TRACE" } { reject } 
  
     append headers as necessary... 
 } 
 

 

 

Am I doing something wrong? Is there some way I can catch that error before it logs? Where did my other sock go?

 

 

Thanks,

 

 

-Chris

8 Replies

  • Hi Chris,

    Is that the full TCL error? I'm not sure why it would occur.

    You could try to capture some info on the issue using catch (Click here) to handle the error:

     
     when HTTP_REQUEST { 
      
         Use catch to handle any error. Save the output to $result for logging of an error or use if successful. 
        if {[catch {HTTP::method} result]}{ 
           log local0. "[IP::client_addr]:[TCP::client_port]: Error running HTTP::method ($result). Headers: [HTTP::request]" 
           reject 
        } else { 
           if {$result eq "TRACE"}{ 
              reject 
           } 
        } 
     } 
     

    Aaron
  • I am seeing the exact same error on occasion in my iRule which does something similar:

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::method] eq "HEAD" } {

     

    reject

     

    }

     

    }

     

     

    TCL error: foo_bar - while executing "HTTP::method"
  • Posted By MocoSpace on 08/01/2010 05:50 AM

     

    I am seeing the exact same error on occasion in my iRule which does something similar:

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::method] eq "HEAD" } {

     

    reject

     

    }

     

    }

     

     

    TCL error: foo_bar - while executing "HTTP::method"

     

     

    Like Aaron mentioned, syntax looks fine, use catch to detect a tcl error and log the request that created an error.
  • Did anyone find the root cause for this error? I get the same thing. A non-descript TCL error with the HTTP::method check. The iRule runs thousands of times a day with no problem, but occasionally logs the error.

     

     

    Does that catch command go immediately after the if statement block that generated the error?

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::method] eq "GET" } {

     

    1

     

    Check for no-cookie loop

     

    if { (([HTTP::uri] contains "?tag=1?tag=1") or ([HTTP::uri] contains "&tag=1&tag=1")) } {

     

    HTTP::redirect "http://foo.com/cookiedetectresponse.jsp"

     

    }

     

    }

     

    2

     

    }

     

     

    Would the catch block go at 1 or 2?

     

     

    Thanks

     

    Mike

     

  • Hi Mike,

     

     

    You can use catch like this:

     

     

    when HTTP_REQUEST { 
     
        Use catch to handle any error. Save the output to $result for logging of an error or use if successful. 
       if {[catch {HTTP::method} result]}{ 
          log local0. "[IP::client_addr]:[TCP::client_port]: Error running HTTP::method ($result). Headers: [HTTP::request]" 
          reject 
       } else { 
           Add the rest of the code here which is triggered if the HTTP::method command succeeds
    
           Check if HTTP::method returned HEAD
          if {$result eq "HEAD"}{
             ...
          }
       } 
    }
    

     

     

    Also, I don't think you'll ever see two question marks in the URI as a question mark delineates the path and the query string. And you normally wouldn't see two of the same query string parameter names like tag=1&tag=1.

     

     

    Aaron
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The only reason I could think of the HTTP::method check failing would be that it can't find a method. Is it possible that there is non HTTP traffic passing through this VIP occasionally? That would freak the HTTP profile out and the method call could fail then.

     

     

    Colin
  • Yeah, so the idea with using catch is that you could trap the error and log the request headers which have been parsed to see what's happening. I think in order for HTTP_REQUEST to trigger a request method URI and HTTP version would need to be parsed. Maybe it's an issue with garbage characters in the method field?

     

     

    Aaron
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Yeah, that's my thinking too Aaron, I wasn't saying not to use catch, as you obviously need to figure out what's triggering the errors, just explaining what I thought could be the root cause. I'm curious to see what's breaking things. :)

     

     

    Colin