I’m trying to load-balance a SOAP interface which requires sticky sessions, in a manner that is transparent to the caller. The first call to the interface does not have a session ID in it, and thus needs to be load-balanced normally. The server will create a session and return the session ID in the response. Subsequent calls to the interface will contain the session ID, and thus need to be routed to the original server. The session IDs are globally unique, so they are ideally suited to be used in a stick table, and I’ve been working on getting that done.
I’m encountering several problems, and I am reluctant to create a topic for each, so let’s see if I can combine them:
Conditional entry in stick table
I have a lua script that parses the incoming request for the session ID. However, there might be none, in which case the script returns nil (though I could easily return something else that is not similar to the session IDs). So the ‘stick on’ must be conditional, because right now, nil gets stored in the stick table and every request without a session ID goes to that server! That’s not what we need.
I now have:
http-request set-var(txn.sessionid) lua.parseElement stick on var(txn.sessionid) if var(txn.sessionid),strcmp(nil) neq 0
but that gives an error because there is no such ACL. This one also doesn’t work:
http-request set-var(txn.sessionid) lua.parseElement acl no_req_session var(txn.sessionid) -m str nil stick on var(txn.sessionid) if !no_req_session
Clearly I am doing something wrong… but what?
In my Lua script, I have the following lines:
local payload_len = txn.sf:res_len() local payload = tostring(txn.sf:res_payload(0,tonumber(payload_len))) core.Alert("Request length is " .. tostring(payload_len)) core.Alert("LUA Starting parse on payload " .. payload)
which should give me the payload of the response in the variable ‘payload’. This is what I see in the log:
[alert] 023/071300 (1968) : Request length is 435 [alert] 023/071300 (1968) : LUA Starting parse on payload .?
Clearly, I’m not successful in converting the whole payload to a string. What am I doing wrong?
Any help with these is greatly appreciated!