fono09
November 22, 2018, 3:11am
1
Hello, I have problem about pattern matching.
I can not call 801 and 802 bidirectionally, but I can call them all at 800.
Do you have any suggestions?
sip.conf
[801]
context=from_phone
type=friend
secret=XXX
canreinvite=no
host=dynamic
dtmfmode=rfc2833
[802]
context=from_phone
type=friend
secret=XXX
canreinvite=no
host=dynamic
dtmfmode=rfc2833
[803]
context=from_phone
type=friend
secret=XXX
canreinvite=no
host=dynamic
dtmfmode=rfc2833
extensions.conf
[from_phone]
exten => 800,1,Dial(SIP/801&SIP/802&SIP/803)
exten => 80Z,n,Dial(SIP/${EXTEN},30)
exten => _X.,n,Set(CALLERID(num)=XXXXXXXX)
exten => _X.,n,Dial(SIP/gw/${EXTEN})
Output of CLI
dialplan show 801@from_phone, and notification when calling from 801 to 802.
CLI> dialplan show 801@from_phone
[ Context 'from_phone' created by 'pbx_config' ]
'_80Z' => 2. Dial(SIP/${EXTEN},30) [extensions.conf:870]
'_X.' => 3. Set(CALLERID(num)=XXXXXXX) [extensions.conf:871]
4. Dial(SIP/gw/${EXTEN}) [extensions.conf:872]
-= 2 extensions (3 priorities) in 1 context. =-
[Nov 22 02:45:50] NOTICE[67][C-00000018]: chan_sip.c:26512 handle_request_invite: Call from '802' (192.168.0.3:5060) to extension '801' rejected because extension not found in context 'from_phone'.
CLI>
Your sip.conf doesn’t match the dialplan show output.
You don’t have a priority one for the pattern _80Z, assuming that the dialplan show output is correct, in relation to the the use of _.
Also:
type=friend is inadvisable, except in special cases (can lead to mis-operation and security breaches)
canreinvite is deprecated in favour of direct media (indicates a failure to code from first principles, but currently they are treated as synonyms).
poing
November 22, 2018, 12:23pm
3
Look closely at how you used n
(next priority) in the dialplan.
80Z
does not have a previous priority.
[from_phone]
exten => 800,1,Dial(SIP/801&SIP/802&SIP/803)
exten => 80Z,n,Dial(SIP/${EXTEN},30)
exten => _X.,n,Set(CALLERID(num)=XXXXXXXX)
exten => _X.,n,Dial(SIP/gw/${EXTEN})
I prefer same
to avoid this kind of issue. I also start every pattern with NoOp()
and a comment inside.
exten => 501,1,NoOp(test)
same => n,NoOp(do something)
same => n,HangUp()
exten => 502,1,NoOp(another one)
same => n,NoOp(something else)
same => n,HangUp()
fono09
November 22, 2018, 2:32pm
4
Thanks a lot david551, poing
I fixed following points, and It seemed like it should be.
every extension has 1st priority
change type friend to peer
canreinvite replaced by dicretmedia(allow|deny)
use NoOp() comment
sip.conf example
[801]
context=from_phone
type=peer
secret=XXXX
host=dynamic
dtmfmode=rfc2833
directmediadeny=0.0.0.0/0
directmediaallow=192.168.X.X/24
extensions.conf
exten => 800,1,NoOp(Call all phones)
same => n,Dial(SIP/801&SIP/802&SIP/803)
same => n,HangUp()
exten => 80Z,1,NoOp(Call each phones)
same => n,Dial(SIP/${EXTEN},30)
same => n,HangUp()
exten => _X.,1,NoOp(OutsideLine)
same => n,Set(CALLERID(num)=XXXXXXXX)
same => n,Dial(SIP/gw/${EXTEN})
same => n,HangUp()