[SR-Users] Strange behavior for unregister() function. Wrong docs? Bug?

Joel Serrano joel at textplus.com
Mon Aug 12 23:13:06 CEST 2019


Hello,

I'm playing around with the unregister() function from the registrar module:

https://www.kamailio.org/docs/modules/devel/modules/registrar.html#registrar.f.unregister

Docs say that that it can be used in REQUEST_ROUTE or FAILURE_ROUTE.

I needed it in REPLY_ROUTE, and before reading the docs I tried it and got
this error:

Aug 12 15:52:44 csbc01 kamailio: CRITICAL: <core> [core/cfg.y:3526]:
yyerror_at(): parse error in config file
/etc/kamailio/csbc/reply_routes.cfg, line 27, column 71: Command cannot be
used in the block#012
Aug 12 15:52:44 csbc01 kamailio[12737]: ERROR: bad config file (1 errors)

But, I have this working on another setup, I compared, and my difference is
that I'm running unregister() inside a route, and calling that route from
reply_route, and that works (and by works, I mean it also does what it is
supposed to do, which is unregister the AoR).

So this doesn't work:

...
onreply_route[MANAGE_REG_REPLY] {
     if(status=~"2[0-9][0-9]") {
         if(($sel(contact.expires)==0) || ($hdr(Expires)==0)){
            if (unregister("location", "$sht(sipserver=>$fU::contact)")) {
                xlog("L_NOTICE", "[usrloc] removed user location\n");
            }
            route(DEL_SIPSERVER);
}
...

But this works:

...
onreply_route[MANAGE_REG_REPLY] {
     if(status=~"2[0-9][0-9]") {
         if(($sel(contact.expires)==0) || ($hdr(Expires)==0)){
            route(UNREG_CUSTOMER);
            route(DEL_SIPSERVER);
}
...

...
route[UNREG_CUSTOMER] {
            if (unregister("location", "$sht(sipserver=>$fU::contact)")) {
                xlog("L_NOTICE", "[usrloc] removed user location\n");
            }
}
...



So I'm in no-mans-land right now, docs say it's not allowed in REPLY_ROUTE,
and if I try it it will fail, but if I try it inside a route, it woks
(hack?).

What is the correct approach here? Should unregister() be valid in
reply_route (like other similar functions, for example: save()) and
therefor docs should be updated and the error in the logs should also be
updated, or if it's really not supported, shouldn't Kamailio not let me use
it anywhere that a ends up being called from reply_route?

I hope I have explained myself correctly. As always, please let me know if
this should be a GH issue instead and I'll happily create it.

Thanks,
Joel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190812/ce650d25/attachment.html>


More information about the sr-users mailing list