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

2020-08-26 Thread Liviu Chircu

On 26.08.2020 15:24, Vitaliy Aleksandrov wrote:

Your suggestion with async(sleep(), resume) is really cool.


Hey, Vitaliy!

I know, right?  All programming textbooks say: "sleep() is bad", "Avoid 
synchronizing with sleep()", "sleep() is hackish", etc.  But, for this 
use case, async(sleep()) helps you achieve this zero-cost polling loop, 
which almost feels like magic!  To me, it looks like the ideal 
solution.  Also, for more precision, you can use async(usleep()).


--
Liviu Chircu
www.twitter.com/liviuchircu | www.opensips-solutions.com

OpenSIPS Summit 2020 Distributed
  www.opensips.org/events/Summit-2020Distributed


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2020-08-26 Thread Vitaliy Aleksandrov

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@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2020-08-21 Thread Liviu Chircu

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@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2020-08-19 Thread Johan De Clercq
More or less the same problem here.
I need to trigger on receiving a register after a push notification, I do
see the REGISTER arriving but nothing happens.
I use 3.1.  Might it be that we have a module issue ?

Op do 20 aug. 2020 om 08:41 schreef Darpan Patel <
darpan.gabani1...@gmail.com>:

> Hello All , i have a query regarding wait_for_event functionality .In
> documentation usage of event is like this :
>
> # wait for callee to register
> $avp(filter) = "aor="+$rU+"@"+$rd
> async( wait_for_event("E_UL_AOR_INSERT","$avp(filter)", "40"),  resume_call);
> # done
> ...
> route[resume_call] {
>   xlog("user $avp(aor) is now registered\n");
>   lookup("location");
>   t_relay();
> }
>
> 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
>
> ___
> Users mailing list
> Users@lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2020-08-19 Thread Darpan Patel
Hello All , i have a query regarding wait_for_event functionality .In
documentation usage of event is like this :

# wait for callee to register
$avp(filter) = "aor="+$rU+"@"+$rd
async( wait_for_event("E_UL_AOR_INSERT","$avp(filter)", "40"),  resume_call);
# done
...
route[resume_call] {
xlog("user $avp(aor) is now registered\n");
lookup("location");
t_relay();
}

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
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users