PJSIP Dialplan For Outbound & Inbound

Can someone help me with PJSIP dialplan for outbound and inbound?
I was trying for last few weeks but nothing working.

I am getting these errors. Please someone help me.

Inbound

res_pjsip_session.c:4044 new_invite: connect: Call (UDP:xx.xxx.xx,xx:5060) to extension ‘+9716xxxx700’ rejected because extension not found in context ‘trunkinbound’.

Outbound
[Apr 5 06:29:25] WARNING[16936][C-00000003]: res_monitor.c:596 __ast_monitor_change_fname: Cannot change monitor filename of channel PJSIP/700-00000003 to null

[Apr 5 06:29:25] WARNING[16936][C-00000003]: func_hangupcause.c:138 hangupcause_read: Unable to find information for channel

You’d probably have to show the dialplan you’re already trying to use, because someone can’t just guess all of the details.

1 Like

Trunk Successfully Registered With These Settings.

[connect]
type=registration
transport=transport-udp
outbound_auth=connect
retry_interval=60
fatal_retry_interval=30
forbidden_retry_interval=30
max_retries=10000
expiration=3600
auth_rejection_permanent=no
line=yes
endpoint=connect
contact_user=+971xxxx2777
server_uri=sip:ims.etisalat.ae:5060
client_uri=sip:+971xxxx2777@ims.etisalat.ae:5060
outbound_proxy=sip:vims-siptrunk.etisalat.ae:5060

[connect]
type=auth
auth_type=userpass
password=XXXXXXX
username=+971xxxx2777@ims.etisalat.ae

[connect]
type=aor
qualify_frequency=60
contact=sip:+971xxxx2777@ims.etisalat.ae:5060
outbound_proxy=sip:vims-siptrunk.etisalat.ae:5060

[connect]
type=identify
endpoint=connect
match=vims-siptrunk.etisalat.ae

[connect]
type=endpoint
transport=transport-udp
context=aashir
disallow=all
allow=ulaw,alaw,gsm,g726,g722,h264,mpeg4
aors=connect
send_connected_line=false
rtp_keepalive=0
language=en
outbound_proxy=sip:vims-siptrunk.etisalat.ae:5060
outbound_auth=connect
from_domain=ims.etisalat.ae
from_user=+971xxxx2777
contact_user=+971xxxx2777
user_eq_phone=no
t38_udptl=no
t38_udptl_ec=none
fax_detect=yes
trust_id_inbound=no
t38_udptl_nat=no
direct_media=no
send_rpid=no
send_pai=no
dtmf_mode=auto
force_rport=yes
rtp_symmetric=yes

And For Dialplan i tried many dialplan but not working.

exten => _X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _X./_700,1,SET(CALLERID(all)=connectcc<+971xxxx2777>)
same => n,Dial(PJSIP/connect/sip:700@ims.etisalat.ae)

exten => _X.,1,Set(CALLERID(all)=“Test <+971xxxx2777>”)
same => n,Dial(PJSIP/${EXTEN}@connect)

Dialplans need context names.

X does not match +. (+ is not a digit and has to be included literally.)

There is no reference to Monitor.

1 Like

Thanks David for your response.
This is dialplan for outbound call. X.
like we can dial number directly (without + sign or country code) like 0501230579
(+971501230579)

Also I need context for incoming. As for now I don’t have any.

Anyone Please?

An example of a pattern that matches numbers beginning with + would be:

_+.

Context names in the dialplan are placed in square brackets, before the corresponding extensions.

The required context name for the call shown as failing because of the extension not found message is “trunkinbound”, However that does not appear in your psip.conf,so assume that you haven’t actual provided a configuration that matches the error messages. The required context name for your pjsip.conf is “aashir”.

1 Like

This is the context for incoming i added in extensions.conf in “/etc/asterisk/extensions.conf”

[aashir]

exten => _+.,1,NoOp(Incoming call to public number ${EXTEN})

exten => _+.,n,GoTo(aashir,777,1)

exten => _+.,n,Hangup()

exten => _777,n,NoOp(Transfered from public context to local extension 777)

exten => _777,n,Dial(PJSIP/${EXTEN},180)

exten => _777,n,Hangup()

And With This I am getting This Error.

NOTICE[2189]: res_pjsip_session.c:4044 new_invite: connect: Call (UDP:10.238.69.33:5060) to extension ‘+971xxxx2700’ rejected because extension not found in context ‘aashir’.

It should get past that step. Did you reload the dialplan? What does “dialplan show” show for it?

However, this line is unreachable:

And this one will fail because there is no priority 1 for extension 777:

This line is also unreachable (and serves no useful purpose):

There is no need to use _ with exact matches.

1 Like

On Sunday 07 April 2024 at 18:19:03, asterisknooob via Asterisk Community
wrote:

This is the context for incoming i added in extensions.conf in
“/etc/asterisk/extensions.conf”

[aashir]

exten => _+.,1,NoOp(Incoming call to public number ${EXTEN})

exten => _+.,n,GoTo(aashir,777,1)

So, you want to send call flow to context “aashir” extension 771 priority 1…

exten => _+.,n,Hangup()

exten => _777,n,NoOp(Transfered from public context to local extension
777)

…but you haven’t defined a priority 1 :frowning:

You start with priority n, which if I understand Asterisk’s habits correctly
means that it will start with priority 4 (since there were 3 preceding
priorities, even if not in this extension).

Also, are those “**” something you’ve added to this posting for emphasis (bad
idea in this sort of situation) or do they literally exist in your dialplan?
If so, remove them.

exten => _777,n,Dial(PJSIP/${EXTEN},180)

exten => _777,n,Hangup()

And With This I am getting This Error.

NOTICE[2189]: res_pjsip_session.c:4044 new_invite: connect:
Call (UDP:10.238.69.33:5060) to extension ‘+971xxxx2700’ rejected because
extension not found in context ‘aashir’.

Try using “_+X.” as your pattern to match a number preceded by a plus sign.

Antony,


This sentence contains exacly three erors.

                                               Please reply to the list;
                                                     please *don't* CC me.
1 Like

A few ‘drive by’ suggestions to improve your dialplan in no particular order:

  1. Whitespace is your friend.

  2. So are comments.

  3. Use the verbose() application. It’s there for a reason.

  4. Use ‘same.’ It is worth it’s weight in gold for so many reasons.

  5. When you post snippets, wrap them in ‘preformatted text tags.’ If you’re a clickey kind of guy, it’s the ‘less than+slash+greater than’ icon. If you’re a cli-weenie, 3 backticks on a line before and after should do the trick.

  6. When things stop making sense, try ‘dialplan show aashir’ or ‘dialplan show 777@aashir.’ What you think your dialplan looks like doesn’t matter. What Asterisk think does.

For example:

(The line above is ```)

; define extensions for the front office
[aashir]
; catch all
        exten = _+.,1,                  verbose(1,[${EXTEN}@${CONTEXT}] - Incoming call to public number ${EXTEN})
        same = n,                       goto(aashir,777,1)
        same = n,                       hangup()

; front lobby phone
        exten 777,1                     verbose(1,[${EXTEN}@${CONTEXT}] - Transfered from public context to local extension 777)
        same = n,                       dial(PJSIP/${EXTEN},180)
        same = n                        hangup()

(The line below is ```)

Note that the above is untested, may contain errors, and reflects my personal ‘coding style.’

On Sunday 07 April 2024 at 20:05:32, sedwards via Asterisk Community wrote:

Note that the above is untested, may contain errors, and reflects my
personal ‘coding style.’

Nice advice, for newbies and probably others too.

Antony


I bought a book on memory techniques, but I’ve forgotten where I put it.

                                               Please reply to the list;
                                                     please *don't* CC me.

WARNING[48693][C-00000003]: pbx.c:4507 __ast_pbx_run: Channel ‘PJSIP/connect-00000002’ sent to invalid extension but no invalid handler: context,exten,priority=aashir,700,1

Getting this error.

Do you now have that context, extension, and priority combination?

If so, please use dialplan show to confirm it.

1 Like

Thank you so much david it’s working i just just priority 1 to 1st line and then in 3rd line like this.

[aashir]

exten => _+.,1,NoOp(Incoming call to public number ${EXTEN})

exten => _+.,n,GoTo(aashir,700,1)

exten => _+.,n,Hangup()

exten => _700,1,NoOp(Transfered from public context to local extension 3333)

exten => _700,n,Dial(PJSIP/${EXTEN},180)

exten => _700,n,Hangup()

Thank you so much all of you. Now that is for one static extension. What if i want dynamically like DID no +97123456700 to exten 700 and +97123456701 to exten 701 and so on. Do I need to change something in dialplan?

Please read up on:

  1. Extension pattern matching.
  2. Manipulating [channel] variables.
  3. Take a stab at it.

If you get stuck, post what you did (the dialplan snippet) and what happened (the console log with verbose > 2.)

I am sorry I am not getting by this.
Can you please show me some template how can I do this?
For example i have DID range 200 and a pilot number.
I want to configure incoming from
+971xxxx2600 to +971xxxx2799
To extension 600 to 799.

Hello Bravo David can you help me with Dialout plan as well?
I am using this one right now but it’s not working.

exten => _X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _X.,n,Set(CALLERID(num)=+971xxxx2700)
exten => _X.,n,Dial(PJSIP/${EXTEN}@connect,45)
exten => _X.,n,Hangup()

I am using Vicidial Btw.