Hi Colin
Yes The Example Is great - Thank you for the Help
I succedd to limit the tcp connection on the pool. but I can count only Active TCP connection but I want to know how much Active MSISDN I have Or the TOtal MSISDN in the persistent Table.
Is there away tho know How much recorded I have in the persistent Table ?
that how I will be abe to know how much MSISDN I have and I will limit by MSISDN.
Here is My Rule
when RULE_INIT {
Set a global max for number of concurrent TCP connections
set ::max_connections 1
Set an HTML response to sent to clients who make a request while the VIP is over the max connection count
set ::html_content_503 "over limit"
set ::html_content_401 "NO MSISDN IN HEADER"
Print debug messages to /var/log/ltm? 1=yes, 0=no
set ::debug 1
Initialize a counter for active connections (don't modify this)
set ::active_connections 0
}
when HTTP_REQUEST {
if { [HTTP::header exists "MSISDN"] } {
If we're over the limit for this connection, send a response
if {$::active_connections > $::max_connections}{
Check if Hndset persist
set pEntry [persist lookup uie [HTTP::header "MSISDN"] ]
if { [string length $pEntry] >= 1 } {
incr ::active_connections 1
persist uie [HTTP::header "MSISDN"]
if {$::debug}{log local0. "Handset persist - Enter (current: $::active_connections). Sent response to [IP::client_addr] , MSISDN [HTTP::header "MSISDN"]"}
} else {
Send a response
HTTP::respond 503 content $::html_content_503
if {$::debug}{log local0. "HTTP::respond - Service Unavailable content (current: $::active_connections). Sent response to [IP::client_addr] , MSISDN [HTTP::header "MSISDN"]"}
Close the connection since CLIENT_CLOSED will decrease active_connections -1
incr ::active_connections 1
TCP::close
Log a message to /var/log/ltm if debug is enabled
}
} else {
We're not over the limit, so check if this is the first HTTP request on the TCP connection.
persist uie [HTTP::header "MSISDN"]
Increment the TCP connection count.
incr ::active_connections 1
if {$::debug}{log local0. "Add MSISDN (current: $::active_connections). Sent response to [IP::client_addr] , MSISDN [HTTP::header "MSISDN"]"}
}
} else {
HTTP::respond 401 content $::html_content_401
}
}
when CLIENT_CLOSED {
A connection was closed, so decrement the global counter
incr ::active_connections -1
if {$::debug}{log local0. "CLIENT_CLOSED (current: $::active_connections). Sent response to [IP::client_addr]"}
}
Again Colin Thank you In Advance