[SR-Users] htable + event_routes + mod-init + htable:expired
Brandon Armstead
brandon at cryy.com
Mon Nov 2 21:41:50 CET 2020
Daniel,
In short kamcmd does not reflect the value set in $sht(server=>auth
::token)
It alternates between being set and not being set (reflecting in kamcmd
htable.dump
root at main:/etc/kamailio# kamcmd htable.dump server
{
entry: 11
size: 1
slot: {
{
name: auth::token
value:
{"data":{"token":{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJDUllZIiwiaWF0IjoxNjA0MzQ2NzgzLCJleHAiOjE2MDQzNTAzODMsIm1ldGhvZCI6InBvc3Q6YXV0aDp0b2tlbiIsImFjY291bnQiOnsiaWQiOiIxIiwiZmlyc3RuYW1lIjoiVGVzdCIsImxhc3RuYW1lIjoiQXJtc3RlYWQiLCJlbWFpbCI6ImJyYW5kb25AY3J5eS5jb20ifSwic291cmNlIjp7ImFkZHJlc3MiOiIzNC45NC4xMjMuMTIxIn19.aFGWqQg31oNnw10XfZ61Xm5Jncvt7RoNri2ZuDJ6yLQ","header":{"alg":"HS256","typ":"JWT"},"payload":{"iss":"CRYY","iat":1604346783,"exp":1604350383,"method":"post:auth:token","account":{"id":"1","firstname":"Test","lastname":"Armstead","email":"
brandon at cryy.com
"},"source":{"address":"34.94.123.121"}},"signature":"aFGWqQg31oNnw10XfZ61Xm5Jncvt7RoNri2ZuDJ6yLQ"}}}
type: str
}
}
}
In the kamailio logs it always shows AUTH_TOKEN_RECEIVED (correctly, with
the correct auth token), kamcmd dump of htable alternates between execution
of this route: htable:expired:server
Exec 1:
auth::time => [timestamp]
Exec 2:
auth::token => token
Exec 3:
auth::time => [timestamp]
So on and so forth, [ kamcmd htable.dump server ] it does not correctly
hold both $sht(server=>auth::time) and $sht(server=>auth::token) like it
should, despite kamailio logs showing the HTTP_AUTH_TOKEN received message
with the correct auth token (100% of the time).
It's almost like there is a race condition when using the modules
http_client_query in both init and expired event route.
When I changed it to the resolved code block above separating the calls and
introducing http_async_client inside htable:expired:server
The result is 100% of the time auth token exists correctly, just like the
logs 100% of the time show the auth token received regardless of
event_route implementation.
So somewhere somehow the problematic config causes the hash table to not
store HTTP_AUTH_TOKEN it receives and logs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20201102/4367f9f9/attachment.htm>
More information about the sr-users
mailing list