Originate call and play a file over CLI

Hi there,

I try to originate a call by CLI and send the call to an extension (my “phone audio” project at ControlPlayback: Wait for other DTMF while playback) which plays an audio file automatically.

My outbound SIP is:

register=raspbx2020:XXXXXXXX@192.168.123.1/raspbx2020

[fritzbox]
defaultuser=raspbx2020
secret=XXXXXXXX
type=peer
dtmfmode=rfc2833
insecure=port,invite
host=192.168.123.1
fromdomain=fritz.box
fromuser=raspbx2020
nat=no
context=line1
allow=g722

With “line1” as context so it autmatically executes this snippet:

[line1]
exten => raspbx2020,1,Answer()

same => n,Set(VOLUME(TX)=2,p) ; p option allows * and # to increase and decrease volume
same => n,AGI(/var/lib/asterisk/playback/pbxaudiobackend_randomfile.pl) ; modify your AGI to just set randomFile only
same => n,ControlPlayback(${randomFile},5000,9,7,0,5,1) ; no more * to restart - also the call control is out of AGI and back in your dial plan quickly

This seems to be a simple task but it didn’t manage to solve it. Do I have to use “Dial” instead of “Answer” in any way?

I initiate the call by entering:

asterisk -rx 'channel originate SIP/0175XXXXXXXX@fritzbox extension line1'

And indeed my phone rings but it terminates immediately with the following error:

[2020-07-25 16:59:41] WARNING[13250][C-00000022]: pbx.c:4453 __ast_pbx_run: Channel 'SIP/fritzbox-00000020' sent to invalid extension but no invalid handler: context,exten,priority=default,line1,1

Maybe no problem for you experts but I don’t know how to solve this :neutral_face:
Why is the extension “invalid”? Because it’s capable of answering incoming calls …

Thanks for any suggestions,

Nico

The context in sip.conf is only used for incoming calls. You need to specify the context explicitly.

Note that chan_sip should not be used for new developments, unless PJSIP will not work, as it has only limited support.

(nat=no is only needed in special cases, and insecure=port is rarely needed for UDP)

1 Like

Hi David,

thank you very much for letting me know.
According to the description, the context can be set by appending it to the “originate” command. I tried it with

channel originate SIP/1234@fritzbox extension line1@fritzbox

and others but same malfunction with identical error.

Will also try to leave out the deprecated sip.conf parameters. I’m using it with my home WiFi PBX universal router thingy.

Thanks,

Nico

It’s not that they are deprecated, but that they are overused, as the result of copying very old guidance designed to minimise support calls. insecure disables various safety checks. It’s main use is to stop your Asterisk verifying the identity of as service provider, because most providers will not do that, but providers. Most providers originate from port 5060, so don’t need the port number check disabling. There is now a better way of achieving former, using remotesecret. I don’t know about the Fritzbox, but it may even be able to authenticate itself.

nat=no disables automatic setting of a parameter when Asterisk detects the use of NAT. It doesn’t disable the detection of NAT.

If the error message is still saying not found in “default”, I don’t understand what is happening.

Dear David, thanks for letting me know! “nat=no” was indeed not neccessary, I removed it and everthing is still working fine. “insecure=port,invite” was neccessary because otherwise I got an authentication error.

But I was wrong, the error message does not say “not found in default”:

[2020-08-02 13:09:56] WARNING[1479][C-00000005]: pbx.c:4453 __ast_pbx_run: Channel 'SIP/fritzbox-00000004' sent to invalid extension but no invalid handler: context,exten,priority=fritzbox,line1,1

So it’s an issue with the handler but what does that mean? Do I maybe really have to use something like Dial() instead of Answer() in my dialplan?

insecure=port,invite is two settings. You probably don’t need the port part.

If you use remotesecret, rather than secret, you can avoid the invite part, and if you can configure the Fritzbox to authenticate itself, you will also not need the invite part, and will have a more secure system.

It means ‘fritzbox,line1,1’` doesn’t exist and that there is no ‘i’ extension in the current context.

What does the following command show?

sudo /usr/sbin/asterisk -r -x 'dialplan show line1@fritzbox'

Oh good thanks, I check that. Might be a bit complicated since the SIP options in FRITZ!Box are limited but additional security is always a good choice.

Hi sedwards, it does say

There is no existence of 'fritzbox' context
Command 'dialplan show line1@fritzbox' failed.

I am confused. Because in the extensions.conf, it is definitely called “line1”.
So that means that it tries to execute the “i extension” because it cannot find the extension “line1”?

The wording is a little bit clumsy, but the context ‘fritzbox’ does not exist.

I think you are conflating settings in sip.conf (where you have an endpoint named [fritzbox]) and extensions.conf (where you have a context named [line1]).

I suspect a command like:

originate SIP/1234@fritzbox extension raspbx2020@line1

may help.

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