Forum Discussion
STREAM::max_matchsize - HELP - Urgent
We are trying to do a URI rewrite and are running into some kind of buffer limitation with streams.
We get a error message when using the following streams directive
STREAMS::max_matchsize 8192
01070151:3: Rule [global_rewrite] error:
line 21: [command is not valid in current event context (HTTP_REQUEST)] [STREAM::max_matchsize 8192]
---------------------------------------------------------
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { ($uri contains "/global/") }
{ pool acecomm }
elseif { ($uri contains "/AC4AC/") or
($uri contains "/awchs54beta/")
}
{
if { $uri contains "/hscs.asmx" } {
pool acecomm
Change the URI of the request, preserving the query arguments, if any.
set args [findstr $uri "?"]
HTTP::uri "/global/hscs.asmx$args"
if {[HTTP::method] equals "POST"} {
Look for /*/hscs.asmx and replace * with "global"
(if you change "global" here you need to change the hard-coded length of 6 below)
Note that this does not fix the Content-Length so we need to do that below
STREAM::expression {@/[^/]*/[Hh][Ss][Cc][Ss].[Aa][Ss][Mm][Xx]@/global/hscs.asmx@}
STREAM::enable
Determine what the original path was
set origpath [findstr $uri "/" 1 "/"]
Store original content-length for POST data
set origlen [HTTP::header "Content-Length"]
Assume replacement string ("global") is 6 characters long, determine difference in
length between "global" and the replacement path
set length_change [expr {6 - [string length $origpath] } ]
set newlen [expr {$origlen + $length_change}]
Set new content length, assuming the stream profile performed exactly one replacement
HTTP::header remove "Content-Length"
HTTP::header insert "Content-Length" [expr {$origlen + $length_change}]
log local0. "origpath=$origpath, change=$length_change, origlen=$origlen"
log local0. "Content length after: [HTTP::header Content-length]"
}
}
}
}
- hoolio
Cirrostratus
Hi arvgidwani, - Lance_Simon_557Historic F5 AccountAaron,
- hoolio
Cirrostratus
Hey Lance, - spark_86682Historic F5 AccountI'll look up later what that command does, but if you want to experiment with it, I think it should be callable (by a bizarre quirk of fate) in LB_SELECTED, which should be before any serverside data is returned.
- agidwani_102403
Nimbostratus
One of the F5 expert was able to help write the script, We are running version 9.3. - Nat_Thirasuttakorn
Employee
my 2 cents - hoolio
Cirrostratus
Hi Spark, - spark_86682Historic F5 AccountBasically, the STREAM profile will buffer data for partial matches; if more than "max_matchsize" would be buffered, the connection will be torn down. This way a regex like "foobarba[^z]+" won't keep matching until the box runs out of memory. The default is 4K, and STREAM::max_matchsize can be use to set it to something else.
- What_Lies_Bene1
Cirrostratus
FYI, I hit this issue recently. I'm not sure I fully understand what a partial match is but regardless, I doubled the value of the buffer, within the HTTP_RESPONSE event:
when HTTP_RESPONSE { STREAM::max_matchsize 8192 STREAM::enable ... }
Note, the actual response payload that was giving me issues was around 64kB. Considering the issue was intermittent, it's possible the buffer relates to all traffic handled by the Virtual Server, not each connection.
Using the STREAM::max_matchsize command in the STREAM_MATCHED event (as I'd seen suggested elsewhere) doesn't work.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com