[OpenSIPS-Users] Cleanup acc & mediaproxy when dialog bye_on_timeout triggers

John Quick John.Quick at smartvox.co.uk
Mon Nov 16 10:29:55 CET 2009


Hi Bogdan

I have changed my script to only use engage_media_proxy() - I believe this has solved the problem with
ending the media proxy sessions.

However, local_route calling acc_aaa_request twice continues to be a problem. Thanks, I was aware of
the risk that gflag will not always work if there are many calls all timing out together. I would
prefer to use flags in the dialog or $DLG_dir, but practical tests showed that this was not possible.
$DLG_dir and $DLG_status both return null, yet $DLG_lifetime returns a proper value. When I tried to
use the function store_dlg_value() in local_route, opensips refused to run and reports an error in the
script.

John

> -----Original Message-----
> From: Bogdan-Andrei Iancu [mailto:bogdan at voice-system.ro]
> Sent: 15 November 2009 19:32
> To: John.Quick at smartvox.co.uk; OpenSIPS users mailling list
> Subject: Re: [OpenSIPS-Users] Cleanup acc & mediaproxy when dialog bye_on_timeout triggers
> 
> Hi John,
> 
> John Quick wrote:
> > I am using the bye_on_timeout_flag within the Dialog module to limit the maximum duration for a
> call.
> > When it is triggered I am having problems cleaning up - i.e. accounting the end of call correctly
> and
> > ending the mediaproxy session. I am not using engage_media_proxy() function, instead preferring
> to
> > have more control with use_media_proxy() and end_media_session().
> >
> > >From a search of the archived questions on this forum I found the trick is to create a
> local_route
> > section and use a check based on is_method("BYE") to determine when to execute acc_aaa_request().
> >
> > This works ok, but it is triggered twice at the end of the call - once for the BYE sent upstream
> and
> > again for the BYE sent downstream. The only solution I could find (I've spent many hours testing
> ideas
> > for this) is the use of a global flag that is toggled each time the local_route block gets a BYE
> > method. Then the code only calls acc_aaa_request() when the global flag is set - i.e. only one in
> > every two times.
> >   if (is_gflag("1")) {
> >       acc_aaa_request("Internal BYE");
> >   }
> >
> >   # Use Global flag 1 to avoid double reporting/accounting of timeout BYE's
> >   if (is_gflag("1")) {
> >       reset_gflag("1");
> >   } else {
> >       set_gflag("1");
> >   }
> >
> > This is not a very elegant or satisfactory solution but it should just about work and hopefully
> not
> > many timeouts will occur anyway. Any suggestions for a better solution would be welcome. I have
> tried
> > Dialog values and transaction flags - they don't work.
> >
> This solution is not correct (using the gflags) - triggering the acc
> from local_route is the right thing to do, but not using the gflags -
> these flags are global and shared by entire opensips which can run (in
> the same time) multiple local_routes for different calls -> so you may
> have a mixture between different calls.
> 
> Try using the "$DLG_dir" script variable
> (http://www.opensips.org/html/docs/modules/devel/dialog.html#id273200)
> to do the acc only for only one direction will be ideally, but reviewing
> the code I think that variable is not populated in local_route - if you
> could give it a try and let me know, it will be great.
> 
> Other idea will be to use the dialog flag or values - you said they do
> not work, even if they should - what seams to be the problem here ?
> 
> > The other problem is how to end the media proxy session. The transaction flags set for the Invite
> are
> > not visible in the local_route block when it is handling the internally generated BYE's so I
> cannot
> > try the normal checks that would be used in the main route block for BYE. Perhaps I should just
> call
> > end_media_session(), but will it even work from local_route? If I change my script to start using
> > engage_media_proxy() will I lose the flexibility of being able to check which calls need media
> proxy
> > and which don't? I don't want them all using it - only those with far-end NAT.
> >
> Shouldn't the media proxy automatically stop when the dialog is
> destroyed ? if you use the enagage_mediaproxy(), I think you do not have
> to explicitly terminate the relay session as the this op will be done
> based on the "dialog destroyed" event.
> 
> If it does not work like this, you can use a dialog flag to remember
> (from INVITE time) if the NAT was detected or not. And in local_route
> you can do an explicit end_mediaproxy().
> 
> Regards,
> Bogdan
> 
> > John Quick
> > Smartvox Limited
> >
> >
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >
> >





More information about the Users mailing list