[solved] [call forwarding]

Hello all,

we have an issue with forwarding calls to external numbers. If extension 303 is set to be forwarded to ext 302, it works fine. But once we want to forward calls from 303 to external number, it’s not working … after some time it fails with DIALSTATUS=CONGESTION. From log:

[Feb 23 10:55:41] VERBOSE[4164] logger.c: [Feb 23 10:55:41] – Executing [0123456789@from-internal:6] Wait(“Local/0123456789@from-internal-119f,2”, “1”) in new stack
[Feb 23 10:55:42] VERBOSE[4164] logger.c: [Feb 23 10:55:42] – Executing [0123456789@from-internal:7] Congestion(“Local/0123456789@from-internal-119f,2”, “20”) in new stack
[Feb 23 10:55:42] VERBOSE[4161] logger.c: [Feb 23 10:55:42] – Local/0123456789@from-internal-119f,1 is circuit-busy
[Feb 23 10:55:42] VERBOSE[4161] logger.c: [Feb 23 10:55:42] == Everyone is busy/congested at this time (1:0/1/0)
[Feb 23 10:55:42] DEBUG[4161] app_macro.c: Executed application: Dial
[Feb 23 10:55:42] VERBOSE[4161] logger.c: [Feb 23 10:55:42] – Executing [s@macro-dial:8] Set(“SIP/303-000008f4”, “DIALSTATUS=CONGESTION”) in new stack
[Feb 23 10:55:42] DEBUG[4161] app_macro.c: Executed application: Set

I’m wondering why does “call string” look like this when forwarding:

“Local/0123456789@from-internal/n||trw”

because when we call external number, it looks like this:

“SIP/DIal/0123456789|300|tw”

…any help is appriciated, thanks for replies.

yaMan

Asterisk 1.4.33.1
FreePBX 2.7.0.5

It looks like that because asterisk has to turn a directory number (extension number) into a technology/data address. You have a degenerate system where the extensions are the same as part of the device data.

Hi david55

Thx for reply. So if that "call string"is ok, do you have any idea why it’s not working? can i provide more info?

y.

Not without seeing priorities 1 to 5 from the dialplan, in the CLI trace.

Hi

not sure if this is the info, if not, please tell me how to get it.

asterisk*CLI> dialplan show app-cf-on
[ Context ‘app-cf-on’ created by ‘pbx_config’ ]
’*72’ => 1. Answer() [pbx_config]
2. Wait(1) [pbx_config]
3. Macro(user-callerid|) [pbx_config]
4. Playback(call-fwd-unconditional) [pbx_config]
5. Playback(please-enter-your&extension) [pbx_config]
6. Read(fromext|then-press-pound||||) [pbx_config]
7. Set(fromext=${IF($[“foo${fromext}”=“foo”]?${AMPUSER}:${fromext})}) [pbx_config]
8. Wait(1) [pbx_config]
[startread] 9. Playback(ent-target-attendant) [pbx_config]
10. Read(toext|then-press-pound||||) [pbx_config]
11. GotoIf($[“foo${toext}”=“foo”]?startread) [pbx_config]
12. Wait(1) [pbx_config]
13. Set(DB(CF/${fromext})=${toext}) [pbx_config]
14. Set(STATE=BUSY) [pbx_config]
15. Gosub(app-cf-on|sstate|1) [pbx_config]
[hook_1] 16. Playback(call-fwd-unconditional&for&extension) [pbx_config]
17. SayDigits(${fromext}) [pbx_config]
18. Playback(is-set-to) [pbx_config]
19. SayDigits(${toext}) [pbx_config]
20. Macro(hangupcall|) [pbx_config]
‘sstate’ => 1. Set(DEVSTATE(Custom:CF${fromext})=${STATE}) [pbx_config]
2. Set(DEVICES=${DB(AMPUSER/${fromext}/device)}) [pbx_config]
3. GotoIf($["${DEVICES}" = “” ]?return) [pbx_config]
4. Set(LOOPCNT=${FIELDQTY(DEVICES|&)}) [pbx_config]
5. Set(ITER=1) [pbx_config]
[begin] 6. Set(DEVSTATE(Custom:DEVCF${CUT(DEVICES|&|${ITER})})=${STATE}) [pbx_config]
7. Set(ITER=$[${ITER} + 1]) [pbx_config]
8. GotoIf($[${ITER} <= ${LOOPCNT}]?begin) [pbx_config]
[return] 9. Return() [pbx_config]
’_*72.’ => 1. Answer() [pbx_config]
2. Wait(1) [pbx_config]
3. Macro(user-callerid|) [pbx_config]
4. Set(fromext=${AMPUSER}) [pbx_config]
5. Set(toext=${EXTEN:3}) [pbx_config]
6. Set(DB(CF/${fromext})=${toext}) [pbx_config]
7. Set(STATE=BUSY) [pbx_config]
8. Gosub(app-cf-on|sstate|1) [pbx_config]
[hook_2] 9. Playback(call-fwd-unconditional&for&extension) [pbx_config]
10. SayDigits(${fromext}) [pbx_config]
11. Playback(is-set-to) [pbx_config]
12. SayDigits(${toext}) [pbx_config]
13. Macro(hangupcall|) [pbx_config]
Include => ‘app-cf-on-custom’ [pbx_config]

-= 3 extensions (42 priorities) in 1 context. =-
asterisk*CLI>

also, we found out that we are able to forward calls to external numbers, but only when call is coming from internal extension. ( eg 303 has calls forwarded to 0123456789, we are able to call 303 from 302 and call is router to 0123456789) but when we call 303 from 0987654321, call is not forwarded to 0123456789 and we receive “TRUNK Dial failed due to CONGESTION HANGUPCAUSE: 21 - failing through to other trunks”)

thanks
yMn

When you find the correct ones, priority 6 will be Wait and Priority 7 will be Congestion.

The Actual CLI output for the call would also be useful, as other messages may give clues.

Hello

this is the output of actual call from 0123456789 to extension 303, forwarded to 0987654321:

<— SIP read from 222.22.22.222:5060 —>
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 111.11.1.1:5060;branch=z9hG4bK6e96b7d6;received=111.11.1.1;rport=5060
From: “0123456789” sip:0123456789@111.11.1.1:5060;tag=as5d52525b
To: sip:0987654321@voip.ourprovider.xx;tag=as55766d46
Call-ID: 4696d5280d3126376db809807d95a486@111.11.1.1
CSeq: 103 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Transmitting (no NAT) to 222.22.22.222:5060:
ACK sip:0987654321@voip.ourprovider.xx SIP/2.0
Via: SIP/2.0/UDP 111.11.1.1:5060;branch=z9hG4bK6e96b7d6;rport
From: “0123456789” sip:0123456789@111.11.1.1;tag=as5d52525b
To: sip:0987654321@voip.ourprovider.xx;tag=as55766d46
Contact: sip:0123456789@111.11.1.1
Call-ID: 4696d5280d3126376db809807d95a486@111.11.1.1
CSeq: 103 ACK
User-Agent: Asterisk PBX
Max-Forwards: 70
Content-Length: 0


-- SIP/DIal-00000047 is circuit-busy

== Everyone is busy/congested at this time (1:0/1/0)
– Executing [s@macro-dialout-trunk:20] NoOp(“Local/10987654321@from-internal-85db,2”, “Dial failed for some reason with DIALSTATUS = CONGESTION and HANGUPCAUSE = 21”) in new stack
– Executing [s@macro-dialout-trunk:21] Goto(“Local/10987654321@from-internal-85db,2”, “s-CONGESTION|1”) in new stack
– Goto (macro-dialout-trunk,s-CONGESTION,1)
– Executing [s-CONGESTION@macro-dialout-trunk:1] Set(“Local/10987654321@from-internal-85db,2”, “RC=21”) in new stack
– Executing [s-CONGESTION@macro-dialout-trunk:2] Goto(“Local/10987654321@from-internal-85db,2”, “21|1”) in new stack
– Goto (macro-dialout-trunk,21,1)
– Executing [21@macro-dialout-trunk:1] Goto(“Local/10987654321@from-internal-85db,2”, “continue|1”) in new stack
– Goto (macro-dialout-trunk,continue,1)
– Executing [continue@macro-dialout-trunk:1] GotoIf(“Local/10987654321@from-internal-85db,2”, “1?noreport”) in new stack
– Goto (macro-dialout-trunk,continue,3)
– Executing [continue@macro-dialout-trunk:3] NoOp(“Local/10987654321@from-internal-85db,2”, “TRUNK Dial failed due to CONGESTION HANGUPCAUSE: 21 - failing through to other trunks”) in new stack
– Executing [10987654321@from-internal:6] Macro(“Local/10987654321@from-internal-85db,2”, “outisbusy|”) in new stack
– Executing [s@macro-outisbusy:1] Progress(“Local/10987654321@from-internal-85db,2”, “”) in new stack
– Executing [s@macro-outisbusy:2] Playback(“Local/10987654321@from-internal-85db,2”, “all-circuits-busy-now|noanswer”) in new stack
– Local/10987654321@from-internal-85db,1 is making progress passing it to SIP/DIal-00000045
– <Local/10987654321@from-internal-85db,2> Playing ‘all-circuits-busy-now’ (language ‘en’)
Really destroying SIP dialog ‘4696d5280d3126376db809807d95a486@111.11.1.1’ Method: INVITE
– Executing [s@macro-outisbusy:3] Playback(“Local/10987654321@from-internal-85db,2”, “pls-try-call-later|noanswer”) in new stack
– <Local/10987654321@from-internal-85db,2> Playing ‘pls-try-call-later’ (language ‘en’)
REGISTER 12 headers, 0 lines
Reliably Transmitting (no NAT) to 222.22.22.222:5060:
REGISTER sip:voip.ourprovider.xx SIP/2.0
Via: SIP/2.0/UDP 111.11.1.1:5060;branch=z9hG4bK46c56a24;rport
From: sip:ourcompany@voip.ourprovider.xx;tag=as71008f50
To: sip:ourcompany@voip.ourprovider.xx
Call-ID: 01cdd4166f5590695b1070104220675d@111.11.1.1
CSeq: 104 REGISTER
User-Agent: Asterisk PBX
Max-Forwards: 70
Authorization: Digest username=“ourcompany”, realm=“voip.ourprovider.xx”, algorithm=MD5, uri=“sip:voip.ourprovider.xx”, nonce=“0c64e666”, response="8d0c4c027367650fabef3a85d1c9b975"
Expires: 120
Contact: sip:ourcompany@111.11.1.1
Event: registration
Content-Length: 0

No it is not, or at least it is missing the important bits. It would have been more use to have the previous information completed.

At a wild guess, you are forwarding the incoming CLI and the service is rejecting the call, either because it thinks that you are trying to forge the CLI, or it relies on it to identify calls as coming from your account.

Hi david55

Thanks for your comments, we finally got it working. We set up Outbound Caller ID in freePBX to Block Foreign CID’s and that helped. Now it looks like this:

<— SIP read from 222.22.22.222:5060 —>
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 111.11.1.1:5060;branch=z9hG4bK2763a5f0;received=111.11.1.1;rport=5060
From: “0123123123” sip:0123123123@111.11.1.1:5060;tag=as5c83e1e8
To: sip:0123456789@voip.ourprovider.xx;tag=as38189b2e
Call-ID: 6a3b4ab57da0d6b721783489757b4b3a@111.11.1.1
CSeq: 103 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY

and “from” field contains our company’s number.

cheers
yMn

Hi,

Thank you very much for sharing this. Had run into the same problem, that my inbound calls (from outside) would not be forwarded, only internal extensions worked.

After many, many hours searching I found this post. At first it did not make any sense, but I decided to try it anyways.

Changing “Outbound Caller ID” to “Block Foreign CID’s” and everything worked… Still dont understand why default “Allow Any DID” doesnt work… Oh well, I am happy now!

Again, thank you for sharing this!