[SR-Users] htable + event_routes + mod-init + htable:expired

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 2 18:50:29 CET 2020


Hello,

On 31.10.20 06:55, Brandon Armstead wrote:
> Running  5.5.0-dev3
>
> modparam("htable", "htable",
> "ipban=>size=8;autoexpire=300;dmqreplicate=1;")
> modparam("htable", "enable_dmq", 1)
> modparam("htable", "dmq_init_sync", 1)
> modparam("htable", "timer_procs", 4)
> modparam("htable", "timer_interval", 5)
> modparam("htable", "db_expires", 1)
> modparam("htable", "htable", "account=>size=4;dmqreplicate=1;")
> modparam("htable", "htable", "server=>size=4;autoexpire=15;")
>
> I'm attempting to retrieve an auth token in the init process and also
> refresh the token upon expiration in the htable:expired event.
>
> I'm seeing some behavior where every other execution of htable:expired
> the variable $sht(server=>auth::token) is set per kamcmd htable.dump
> server, however xinfo() reports that the token was retrieved in the
> variable $sht(server=>auth::token).


I don't really get what you meant above, can you explicitly tell what is
printed in the logs and kamcmd output in each case and what you expected
to be there?

Cheers,
Daniel

>
> Please see remaining event route config below:
>
> event_route[htable:mod-init]{
>
>     # generate auth token into 
>
>
>     http_client_query("https://www.cryy.com/api/auth/token",
> '{"email": "brandon at cryy.com", "password":"XXXX"}', "$var(result)");
>
>
>     sht_lock("server=>auth::token");
>
>
>     $sht(server=>auth::token) = $var(result);
>
>
>     sht_unlock("server=>auth::token");
>
>     
>
>     xinfo("AUTH_TOKEN_RECEIVED, $sht(server=>auth::token)");
>
> }
>
>
> event_route[htable:expired:server]{
>
>     # process expired htable, renew auth token
>
>     xinfo("AUTH_TOKEN_EXPIRED, lets retrieve a new one");
>
>
>     http_client_query("https://www.cryy.com/api/auth/token",
> '{"email": "brandon at cryy.com", "password":"XXXX"}', "$var(result)");
>
>
>     sht_lock("server=>auth::token");
>
>     $sht(server=>auth::time) = $TS;
>
>     $sht(server=>auth::token) = $var(result);
>
>     sht_unlock("server=>auth::token");
>
>
>     xinfo("AUTH_TOKEN_RECEIVED, $sht(server=>auth::token)");
>
>     xinfo("AUTH_TOKEN_TIME, $sht(server=>auth::time)");
>
> }
>
>
> I've tried both with locking and unlocking.  Also one last thing worth
> mentioning is that on the alternation where kamcmd htable.dump server
> shows no auth token, $sht(server=>auth::time) is available, when the
> auth token is visible in kamcmd htable.dump server there is no
> sht(server=>auth::time) returned.
>
> Also just to be explicitly clear -- xinfo() always
> returns AUTH_TOKEN_RECEIVED correctly in both event routes.
>
> Perhaps I'm over looking something -- thank you for the help in advance.
>
> - Brandon
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20201102/3f8aadc1/attachment.htm>


More information about the sr-users mailing list