Forum Discussion
beefy80
Apr 07, 2014Nimbostratus
John
I had to enhance your code slightly as the payload messages are quite small and therefore client_data event was not getting triggered again as the LTM has already buffered the rest of the data. I have therefore now added a check to see if we already have the data or not and if we do TCP::release. I cannot see a more affiant way of doing this, what do you think?
when CLIENT_ACCEPTED {
TCP::collect 2
set header_collected "false"
}
}
when CLIENT_DATA {
if { not ($header_collected) } {
Comment out one of the two binary scan lines below.
use this form if lower order byte is last (big endian order)
binary scan [TCP::payload] S message_length
use this form if lower order byte is first (little endian order)
binary scan [TCP::payload] s message_length
as the message length collected does not include itself add 2 more onto the result
set message_length [expr { $message_length + 2 }]
if { $message_length > 0 } {
set header_collected "true"
collect data with the required length
TCP::collect $message_length
check if we already have the required data in the buffer if so
capture the payload in vars and release it
if {[TCP::payload length] == $message_length } {
set vars with payload info for HSL logging later
set my_req_msg_payload [TCP::payload]
set my_req_msg_length [TCP::payload length]
release the data already collected
TCP::release
}
}
} else {
if we are here the actual message is collected.
set my_req_msg_payload [TCP::payload]
set my_req_msg_length [TCP::payload length]
TCP::release
}
}