Potential incorrect handling of SIP 404?

Hi all,

So Im getting this with both Elastix, Trixbox & AsteriskNOW using a variety of FreePBX versions.

When I dial a number that does not exist (Invalid / No-such-number) from my asterisk box, I get the message “All circuits are busy now, please try your call again later”. I think I should be getting the message “Your call cannot be completed as dialed, please check the number and try again”.

Ive tried this via a SIP trunk & an IAX2 trunk to my ITSP.

Turning on SIP Debug I get:
<— SIP read from 202.180.76.161:5060 —>
SIP/2.0 404 Not Found

So, reading here:
http://www.voip-info.org/wiki-Asterisk+variable+DIALSTATUS
And here:
http://www.voip-info.org/wiki/view/Asterisk+variable+hangupcause
It appears as though 404 Not Found is correct, however I believe the box should be handling it as CONGESTION but instead its coming back with CHANUNAVAIL.

When dialing a number I know is invalid, it looks like this from the asterisk console:
– Executing [[email protected]:20] Dial(“SIP/195-09ac4fc0”, “IAX2/099294922/4061756|300|”) in new stack
– Called 099294922/4061756
– Call accepted by 202.180.76.166 (format alaw)
– Format for call is alaw
– IAX2/099294922-16386 is making progress passing it to SIP/195-09ac4fc0
– Hungup ‘IAX2/099294922-16386’
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [[email protected]:21] Goto(“SIP/195-09ac4fc0”, “s-CHANUNAVAIL|1”) in new stack
– Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)
– Executing [[email protected]:1] GotoIf(“SIP/195-09ac4fc0”, “1?noreport”) in new stack
– Goto (macro-dialout-trunk,s-CHANUNAVAIL,3)
– Executing [[email protected]:3] NoOp(“SIP/195-09ac4fc0”, “TRUNK Dial failed due to CHANUNAVAIL - failing through to other trunks”) in new stack
– Executing [[email protected]:5] Macro(“SIP/195-09ac4fc0”, “outisbusy|”) in new stack
– Executing [[email protected]:1] Playback(“SIP/195-09ac4fc0”, “all-circuits-busy-now|noanswer”) in new stack
– <SIP/195-09ac4fc0> Playing ‘all-circuits-busy-now’ (language ‘en’)

So Ive been trying to read through my extensions.conf file, thinking I might be able to see something in there that I can adjust to correct it, but to be honest I wouldnt have a clue where to start, nor am I entirely sure what I can manually change without having FreePBX change it back…

Any pointers / suggestions would be greatly appreciated.

Cheers

Chill.

From what I’ve read is that the “All circuits are busy” message is part of the dialplan security. The idea is that if someone attempts to hack your PBX by brute force guessing of extensions then they receive this message. It’s ambiguous enough that it discourages hackers.

Normally, the extension is known or there is a dialplan rule that says what to do with calls to the PBX. If no rules match, then the “All circuits are busy” message appears.

Unfortunately, if you are trying to troubleshoot a problem and receive this message then it can be very frustrating. Usually the source of the problem is mismatched extension numbers and secrets (passwords).

Hi there, did you ever get anywhere with this?

I have a similar problem at a small call centre where outgoing calls are failing for a number of reasons (busy, unobtainable, internet line issues etc etc), but all being presented as an “all-circuits busy” to the user.

This is confusing them no-end and we are being called un-necessarily when they are dialling invalid numbers.

I have looked at the macro’s and they seem not to use the HANGUPCAUSE method at all, which is probably why it is falling to the generic message that they are receiving.

Has anyone got a workaround for this using the HANGUPCAUSE ?

Thanks

Neil

Hi Neil,

Unfortunately not, I havent got anywhere further with it… I’ve got so many things on at once this has unfortunately been pushed to one side now. I also have a small call-center so I understand the frustration :frowning:

If you find anything, let me know. Im hoping to do some more research during the week.

Cheers

Chill.

Hi!

We’ve encountered a problem like yours, but with Zap trunks (Sangoma E1).
I’ve patched FreePBX to handle this correctly, by checking $HANGUPCAUSE.
[Please note that a few ISDN hangup causes are not treated yet]

I’ll try to submit the patch to the devs, hopefully it’ll get included in the next versions of FreePBX.

Hope this helps!

— ./modules/core/functions.inc.php.orig 2008-09-22 04:19:18.000000000 +0200
+++ ./modules/core/functions.inc.php 2009-02-09 11:35:18.000000000 +0100
@@ -1150,6 +1151,11 @@
*
* Modified both Dial() commands to include the new TRUNK_OPTIONS from the general
* screen of AMP

  •   	 *
    
  •   	 * MODIFIED (Nicson)
    
  •   	 *
    
  •   	 * Modified to check HANGUPCAUSE
    
  •   	 *
      	 */
      	$ext->add($context, $exten, '', new ext_set('DIAL_TRUNK', '${ARG1}'));
      	$ext->add($context, $exten, '', new ext_execif('$[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]', 'Authenticate', '${ARG3}'));
    

@@ -1206,6 +1212,53 @@
$ext->add($context, $exten, ‘’, new ext_playtones(‘congestion’));
$ext->add($context, $exten, ‘’, new ext_congestion(20));

  •   	// added by Nicson
    
  •   	$exten = "s-UNALLOC";
    
  •   	$ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Unallocated/Unassigned number - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_progress());
    
  •   	$ext->add($context, $exten, '', new ext_playback('ss-noservice|noanswer'));
    
  •   	$ext->add($context, $exten, '', new ext_busy(20));
    
  •   	$exten = "s-NONET";
    
  •   	$ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting No route to specified transit network - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_progress());
    
  •                    $ext->add($context, $exten, '', new ext_playback('ss-noservice|noanswer'));
    
  •   	$ext->add($context, $exten, '', new ext_busy(20));
    
  •   	$exten = "s-NOROUTE";
    
  •   	$ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting No route to destination - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_progress());
    
  •                    $ext->add($context, $exten, '', new ext_playback('ss-noservice|noanswer'));
    
  •   	$ext->add($context, $exten, '', new ext_busy(20));
    
  •   	$exten = "s-CHANUNACCEPT";
    
  •   	$ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Channel unacceptable - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_playtones('busy'));
    
  •   	$ext->add($context, $exten, '', new ext_busy(20));
    
  •   	$exten = "s-REJECT";
    
  •   	$ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Call Rejected - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_playtones('busy'));
    
  •   	$ext->add($context, $exten, '', new ext_busy(20));
    
  •   	$exten = "s-CHANGED";
    
  •   	$ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Number Changed - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_playtones('busy'));
    
  •   	$ext->add($context, $exten, '', new ext_busy(20));
    
  •   	$exten = 's-CONGESTION';
    
  •   	// added by Nicson
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "1"]', 's-UNALLOC,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "2"]', 's-NONET,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "3"]', 's-NOROUTE,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "6"]', 's-CHANUNACCEPT,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "11"]', 's-BUSY,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "12"]', 's-NOANSWER,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "13"]', 's-NOANSWER,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "15"]', 's-REJECT,1'));
    
  •   	$ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "16"]', 's-CHANGED,1'));
    
  •   	// end added by Nicson
    
  •   	$exten = '_s-.';
      	$ext->add($context, $exten, '', new ext_gotoif('$["x${OUTFAIL_${ARG1}}" = "x"]', 'noreport'));
      	$ext->add($context, $exten, '', new ext_agi('${OUTFAIL_${ARG1}}'));
    

@@ -1272,7 +1325,53 @@
$ext->add($context, $exten, ‘’, new ext_playtones(‘congestion’));
$ext->add($context, $exten, ‘’, new ext_congestion(20));

  •                    // added by Nicson
    
  •                    $exten = "s-UNALLOC";
    
  •                    $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Unallocated/Unassigned number - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_answer());
    
  •                    $ext->add($context, $exten, '', new ext_playback('ss-noservice'));
    
  •                    $ext->add($context, $exten, '', new ext_busy(20));
    
  •                    $exten = "s-NONET";
    
  •                    $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting No route to specified transit network - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_answer());
    
  •                    $ext->add($context, $exten, '', new ext_playback('ss-noservice'));
    
  •                    $ext->add($context, $exten, '', new ext_busy(20));
    
  •                    $exten = "s-NOROUTE";
    
  •                    $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting No route to destination - giving up'));
    
  •   	$ext->add($context, $exten, '', new ext_answer());
    
  •                    $ext->add($context, $exten, '', new ext_playback('ss-noservice'));
    
  •                    $ext->add($context, $exten, '', new ext_busy(20));
    
  •                    $exten = "s-CHANUNACCEPT";
    
  •                    $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Channel unacceptable - giving up'));
    
  •                    $ext->add($context, $exten, '', new ext_playtones('busy'));
    
  •                    $ext->add($context, $exten, '', new ext_busy(20));
    
  •                    $exten = "s-REJECT";
    
  •                    $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Call Rejected - giving up'));
    
  •                    $ext->add($context, $exten, '', new ext_playtones('busy'));
    
  •                    $ext->add($context, $exten, '', new ext_busy(20));
    
  •                    $exten = "s-CHANGED";
    
  •                    $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting Number Changed - giving up'));
    
  •                    $ext->add($context, $exten, '', new ext_playtones('busy'));
    
  •                    $ext->add($context, $exten, '', new ext_busy(20));
    
  •                    // end added by Nicson
    
  •   	$exten = '_s-.';
    
  •                    // added by Nicson
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "1"]', 's-UNALLOC,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "2"]', 's-NONET,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "3"]', 's-NOROUTE,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "6"]', 's-CHANUNACCEPT,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "11"]', 's-BUSY,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "12"]', 's-NOANSWER,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "13"]', 's-NOANSWER,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "15"]', 's-REJECT,1'));
    
  •                    $ext->add($context, $exten, '', new ext_gotoif('$["${HANGUPCAUSE}" = "16"]', 's-CHANGED,1'));
    
  •                    // end added by Nicson
      	$ext->add($context, $exten, '', new ext_gotoif('$["x${OUTFAIL_${ARG1}}" = "x"]', 'noreport'));
      	$ext->add($context, $exten, '', new ext_agi('${OUTFAIL_${ARG1}}'));
      	$ext->add($context, $exten, 'noreport', new ext_noop('TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks'));
    

— ./extensions.class.php.orig 2009-02-09 11:38:18.000000000 +0100
+++ ./extensions.class.php 2009-02-09 11:34:07.000000000 +0100
@@ -569,6 +569,12 @@
}
}

+class ext_progress extends extension {

  • function output() {
  •   return"Progress";
    
  • }
    +}

class ext_privacymanager extends extension {
function output() {
return “PrivacyManager(”.$this->data.")";

If you submit it via the bug report with the patch as an attachment I’m sure they will look at it. You’ll find it at the bottom of every we page in the center 3 item down under Development

Fantastic ! Thank you.

We will try this over the coming couple of weeks and feed back.

Kind regards

Neil

I attest that the patch works perfectly. Wonder why it hasn’t been added…

Well. Thanks a lot nicson !!

I had been battling with this thing for several months now!

Any ideas why this hasn’t been adopted?

Also I can’t see the bug/entry in the trac, anyone have a reference as trying to apply the patch myself is failing, i think thats due to forum encoding/screwing the formatting though

what’s the ticket number, it’s possible it’s just an oversight…

I’m suffering from this problem too, it seems calls through our SIP provider to non-existant or otherwise problem numbers are giving an “all circuits are busy” message and confusing my call centre staff.

I’ve searched through the bug tracking system and can’t find this listed - but it’s not a system I’m familiar with so I may have missed it. Anyway, I’ve submitted the bug myself as ticket 3805

Hopefully this will get resolved in a future release. Meanwhile can anybody explain to a non developer like myself how to apply the patch?

Thanks,

Tim

Could someone please guide me on how to add the patch? Is it as easy as copy and pasting the aboce code into functions.inc.php? Or do I have to create a module to upload via Freepbx?

Thanks,

Mark

I´m sorry asking again but the second file patch.txt cannot be applied correctly. I tried “patch <patch.txt” and added the file location when patch tool asked for it but i get a error at line 4 with the sign “*”. MAy im missing a thing to the patch command? Would be nice if someone could help me out.

May someone can explain me how to apply this patch to an working 2.6 Instalaltion too?

This feature is added to FreePBX 2.7 that is in svn right now. 2.7 will be released in a near future as soon as the fax functions are tested.

Please read more here: http://www.freepbx.org/trac/roadmap and the ticket here

I will not try to explain how to patch the above because it explained almost everywhere on the net how to use the patch command.

Thanks for your comment, the patch command isn´t the problem. My question is maybe a basic question but changing the 2 php files doesn´t efect the dialplan, correct? What does i have to do to get these changes take effekt in the dialplan. Would be nice of you to get get some hint.

If you enter the above in the files (you need to change two files), and save them, all you have to do then is to save some setting in FreePBX and the dialplan will be updated.

blanchae, the change in dialplan was to enhance the report back to the caller calling out of the pbx, I fail to see how this affects hackers trying to brute force guessing extensions.

This update in the dial plan is to enhance the failure message to caller if trunk report this:

  • HANGUPCAUSE 1 = Unallocated number, or SIP 404 not Found
    This means that the number dialed is not found, usually a number dialed wrong.

  • HANGUPCAUSE 28 = Address Incomplete, or SIP 484 Address Incomplete
    This means that the number dialed is incomplete, like dialing a number to short

  • HANGUPCAUSE 18 = No User Responding, or SIP 408 Request Timeout

  • HANGUPCAUSE 19 = No Answer From The User, or SIP 480 Temporarily unavailable, SIP 483 To many hops
    This means that there was no answer from the dialed number.

Oh, saddly my last comment was not fully postet.
I´ve got problems applying this patch with the patch command. Here´s my output:

[email protected]:/var/www/html/admin/modules/core $ patch <./patch.txt
patching file functions.inc.php
patch: **** malformed patch at line 4: *

May i forot some parameters to the patch command?

Mysterious, the patch posted above only work with the specific version of FreePBX where the diff was generated.
As I don’t know which version of FreePBX the diff was generated from or your version of FreePBX I actually can’t help with your request.

I advice you to wait until FreePBX 2.7 is out.