[OpenSIPS-Users] wait_for_event(event,filter,timeout)

Vitaliy Aleksandrov vitalik.voip at gmail.com
Wed Aug 26 12:24:36 EST 2020

Hi Liviu,

Your suggestion with async(sleep(), resume) is really cool. I use 
async(wait_for_event(), resume) a bit differently and pause a call for 
another type of event that is generated upon reception of an external 
notification (SIP or clusterer) and had to patch event_routing, add a 
timer and forcibly call "resume" route when it expires. But even my use 
case can be rewritten by setting some global flag or cache_srote() from 
an event handler and checking it from resume route.

I completely forgot that haven't sent that patch for review.
> On 20.08.2020 09:37, Darpan Patel wrote:
>> But in my case after 40 seconds it's not trigger resume_call route, so resume_call only called after the event will succeed ? I want to implement a feature like if callee is not registered till 40 seconds then relay call to PSTN Gateway .thanks alot in advance .
>> regards ,
>> Darpan Patel
> Hey Darpan,
> From how I recall the code, async() statements have no timeout.  So 
> that async(wait_for_event()) will be stuck forever until that 
> registration arrives -- I may be wrong here, maybe Bogdan can offer 
> more clarifications as he delivered some work on supporting async 
> statement timeouts roughly 6 months ago.
> Alternatively, I suggest a simpler solution, which will actually be 
> quite performant:
>     "as long as the lookup() keeps failing due the user still being 
> offline, keep doing
>       async(sleep(1 second), route_lookup_user).  Start with an $avp() 
> value of 40 and
>       keep decrementing it, so you know when to give up doing those 
> sleep() operations,
>       after 40 decrements (seconds)."
> Reasons why this close to optimal:
> * usrloc lookup() operations are hyper-optimized, since all AoRs are 
> held in an AVL tree which sits in a wide hash.  The lookup cost is 
> essentially zero.
> * async(sleep()) is safe & straight-forward.  It will also help you 
> maintain a high throughput (thousands of CPS)
> * the user experience will be quite OK, with the caller receiving the 
> call 1 second after the registration, on the worst case
> Best regards,
> -- 
> Liviu Chircu
> www.twitter.com/liviuchircu  |www.opensips-solutions.com
> OpenSIPS Summit 2020 Distributed
>    www.opensips.org/events/Summit-2020Distributed
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200826/479fdea3/attachment.html>

More information about the Users mailing list