[SR-Users] Force registrations on Kamailio save()

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 19 18:39:01 CEST 2020


Hello,

sip registration is kept for the duration of expires value and "older
one" is relative and might be something that results in unwanted
behaviour. For example, if you have 2 end points for the same user, one
fixed phone registering every hour and one mobile app registering every
5min, when the mobile app changes mobile network/wifi and registers
again with a new contact, you may end up removing the contact
corresponding to the fixed phone, instead of the previous contact for
mobile app (which has an invalid IP due to migration to another
network). So I would rather be very careful with removing the older
contacts.

That being said, you can fetch all the contacts for a user using
reg_fetch_contacts(), loop with a while through them and keep the ruid
attribute for the contact you want to remove and then use unregister()
for it. Here are relevant examples that can help implementing it:

  *
https://www.kamailio.org/docs/modules/stable/modules/registrar.html#idm909

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

If you ensure the same expires value for registrations, practically the
oldest contact has the lowest value for $ulc(caller=>expires). If
devices use different expires values, then you end up in the case
described by my remark above. You can also test the last_modified field
to decide what is the oldest contact.

Cheers,
Daniel

On 19.08.20 16:35, Duarte Rocha wrote:
> Greetings, 
>
> I'm currently creating a Kamailio with registrations and i'm unsure
> how to use the save() function.
>
> I want to limit the number of contacts for the AOR to 2. I also want
> to force the registration of new contacts even if the maximum number
> is reached, removing the older ones.
>
> I saw that on opensips i could use the flags "fc2" for this but they
> aren't available on Kamailio's save(). I'm using the max_contacts
> parameter but in the docs it states the once the limit is reached, it
> will reject new Registers.
>
> How can i implement the force registration behaviour here?
>
> Best Regards,
>
> Duarte Rocha
>
> _______________________________________________
> 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/20200819/8342f8a1/attachment.htm>


More information about the sr-users mailing list