Forum Discussion

Jack_Huang_5191's avatar
Jack_Huang_5191
Icon for Nimbostratus rankNimbostratus
Jul 15, 2005

When v4.5.10 irule code migrate to v9.1, it can't work.

I have a right v4.5.10 irule script. It works well in the big-ip 4.5.10. The function of this script is to traffic http uri contains .sdp, 3gp, mov, mp4 to a pool, sun_stream_servers. Other http uri traffics to real_stream_servers. The 4.5.10 script is as follows:

if ( http_uri matches_regex ".sdp" ) {
use (Sun_Stream_Servers)
}
else if ( http_uri matches_regex ".3gp" ) {
use (Sun_Stream_Servers)
}
else if ( http_uri matches_regex ".mov" ) {
use (Sun_Stream_Servers)
}
else if ( http_uri matches_regex ".mp4" ) {
use (Sun_Stream_Servers)
}
else {
use (Real_Stream_Servers)
}

Now, I have migrated it to v9.1. I found it can't work well. I use the default http profile. The new 9.1 script is as follows:

when HTTP_REQUEST {
  if { [HTTP::uri] matches_regex ".sdp" } {
     pool Sun_Stream_Servers
  } elseif { [HTTP::uri] matches_regex ".3gp" } {
     pool Sun_Stream_Servers
  } elseif { [HTTP::uri] matches_regex ".mov" } {
     pool Sun_Stream_Servers
  } elseif { [HTTP::uri] matches_regex ".mp4" } {
     pool Sun_Stream_Servers
  } else {
     pool Real_Stream_Servers
  }
}

4 Replies

  • matches_regex is too much overhead. You should probably just use the contains rational operator. You can also chain the conditions up with OR's. I've thrown in some logging that you can remove if things are working for you. Check in the /var/log/ltm file for the output.

    when HTTP_REQUEST {
      log local0. "found uri: [HTTP::uri]"
      if { [HTTP::uri] contains ".sdp" ||
           [HTTP::uri] contains ".3gp" ||
           [HTTP::uri] contains ".mov" ||
           [HTTP::uri] contains ".mp4" } {
        log local0. "Using Sun_Stream_Servers"
        pool Sun_Stream_Servers
      } else {
        log local0. "Using Real_Stream_Servers"
        pool Real_Stream_Servers
      }
    }

    You could probably optimize this further by slapping the extensions in a string data group and use the findclass command. But for only a few extensions this is still manageable.

    -Joe
  • By the way, you could use the ends_with operator instead of contains if you know your uri will always end with the extension. I was assuming in my last post that you may have some HTTP GET variables trailing past the extension.

     

     

    -Joe
  • I forget to say that the application is a RTSP request rather than HTTP. Because in v4.5.10, we think the RTSP is similar to HTTP. We use HTTP uri to match the string.

     

     

    I have tested your script, but it can not run correctly. I think maybe I need to use TCP request to trigger the RTSP.
  • The HTTP_REQUEST event (and all other HTTP_* events) will only work if you have a http based profile associated with the virtual. As for RTSP, I'm not sure what adding a HTTP profile to that virtual will do. It might break the application. I would suggest you post this to the iRules v9 forum as the iRules experts don't monitor this one.

     

     

    In the mean while I'll see what I can dig up but I personally don't have a environment to test a RTSP stream.

     

     

    -Joe