So far it is working quite well. I need to add handling for error conditions and other refinements. I learned a lot about i-rules with this one.
when CLIENT_ACCEPTED {
TCP::collect 44
}
when CLIENT_DATA {
set ConStr [TCP::payload 44]
set SessionID [substr [getfield $ConStr "@" 2] 0 " " ]
log local0.info $SessionID
set PersistTo [session lookup uie $SessionID]
log local0.info $PersistTo
if { $PersistTo equals "" } {
pool [LB::server pool]
log local0.info "No session ID, load balancing the connection."
} else {
pool [LB::server pool] member $PersistTo
log local0.info "$SessionID sent to $PersistTo"
}
}
when SERVER_CONNECTED {
if { $PersistTo equals "" } {
session add uie $SessionID [IP::server_addr]:[serverside {TCP::remote_port}]
log local0.info "Added $SessionID to [IP::server_addr]:[serverside {TCP::remote_port}]"
} else {
log local0.info "$SessionID already exists to $PersistTo"
}
}