Hangup() after Dial()

Hi, this is a very simple question to understand the role of Hangup(). Do I need to explicitly use Hangup() after the Dial() app? Bear in mind that in my use cases I always send the outbound calls via a PJSIP channel. If I don’t use Hangup() after Dial(), are there any concerns in this?

If the call completes normally, and you don’t use the g option, nothing after Dial will be run, so the Hangup will be redundant.

For unsuccessful calls, the reasons for considering an explicit hangup are:

  1. you want to override the clearing cause code;
  2. as as a safety measure if you make complex use of extensions patterns, so that priorities from less specific, but compatible, patterns don’t get run after the intended end of the dialplan.

If you use g, you are already making decisions to override the normal logic, so it wll depend on what the intent of the dialplan is.

The other redundant application call commonly encountered is Answer() at the start of a dialplan. For unsuccessful calls you may never want the call answered, and for successful calls it can increase the billed call duration for the caller.

Thanks for the elaborate response David. I’ll take that into consideration in my projects.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.