Closed sesardelaisla closed 1 year ago
I've managed to move forward. chan_sip.so module was not being loaded because the following line in modules.conf:
noload => chan_sip.so
I commented it out and now I can issue sip commands, and trunks seems to be read. However, despite I can use my provider's SIP data to do outbound calls from a softphone app in a very simple way, registration is not being done from Asterisk for MovistarOut, which is the trunk outbound profile I need:
[01:13:55] INFO: Executing command from stdin: asterisk -rx 'sip show peers'
[Jul 26 01:13:55] -- Remote UNIX connection
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
100/100 192.168.0.1 D Yes Yes 47661 Unmonitored
101/101 (Unspecified) D Yes Yes 0 Unmonitored
102/102 (Unspecified) D Yes Yes 0 Unmonitored
MovistarIn/949xxxxxx 10.31.255.134 Yes Yes 5060 Unmonitored
MovistarOut (Unspecified) Yes Yes 0 Unmonitored
5 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 3 offline]
[Jul 26 01:13:55] -- Remote UNIX connection disconnected
Asterisk ending (0).
I am wondering whether Asterisk in handling this in a different way. Will continue digging on this but it would be great if I get some help from anyone. Thanks!
I have been doing tests with another addon for the purpose of doing outbound calls and it works. It is not perfect because calls usually should be needed to be dialed twice for them to make my phone ring. Just saying for reference, because another similar componente (addon) works from my current setup. That's what I wanted to do to try to filter errors.
Having said that, is there any limitation with this Asterisk addon when it comes to outbound connectivity (WAN)?
I surrendered. I've found no way to setup the SIP config correctly so switched to PJSIP. At last, I can receive calls, although I can't see caller id info in the remote phone for the moment. Will try to figure it out.
I'm sorry @sesardelaisla, but I have no straight help to provide to you. But,
What other add-on are you referring to?
Having said that, is there any limitation with this Asterisk addon when it comes to outbound connectivity (WAN)?
Not that I know of. And if there is, it's probably something we can address.
I am referring to DSS VoIP Notifier. It works, but it is not reliable, at least for the telco I am subscribed to.
One difference I can see is that our add-on uses host network while DSS VoIP Notifier doesn't.
our add-on uses host network while DSS VoIP Notifier doesn't
That's actually something that came into my mind. You mean that they use some sort of bridged host network instead, don't you?
By the way, sorry for the off-topic question, but can you tell where I can get full logs from? I enabled debug for trying to figure out how the "From" string is being sent by Asterisk, so I can check what it is actually being sent. However, the screen is not long enough to capture all logs and it scrolls too fast. ;) Addon logs in HASS config contain the same amount of lines.
Are they stored in any file somewhere?
You mean that they use some sort of bridged host network instead, don't you?
Yeah, I think bridged network is the default.
By the way, sorry for the off-topic question, but can you tell where I can get full logs from? I enabled debug for trying to figure out how the "From" string is being sent by Asterisk, so I can check what it is actually being sent. However, the screen is not long enough to capture all logs and it scrolls too fast. ;) Addon logs in HASS config contain the same amount of lines.
Are they stored in any file somewhere?
From the community Terminal add-on with protection mode disabled:
docker logs -f addon_b35499aa_asterisk
docker logs -f addon_b35499aa_asterisk
Tried this but response is:
Error response from daemon: No such container: addon_b35499aa_asterisk
Do note that my container's hostname is:
3e533915-asterisk
Tried the following option and it works:
docker logs -f addon_3e533915_asterisk
You can check the containers with docker ps
btw.
Just another quick question. Is it possible to connect to Asterisk through terminal so I can type commands directly and see the output on the fly, instead of having to send service calls on a per command basis?
How are the custom files handled? Just saying because this is my current dialplan in custom/extensions.conf:
[general]
static=yes
writeprotect=yes
autofallthrough=yes
extenpatternmatchnew=yes
clearglobalvars=no
[default]
exten => _X.,1,Hangup(21)
;same => _[67]XXXXXXXX,1,NoOP(Llamadas a moviles)
same => n,set(PJSIP/Movistar_endpoint, ${CALLERID(all)})=949xxxxxx <949xxxxxx>
;same => n,NoOp(CALLERID(all))
;same => n,Set(CALLERID(all)=949xxxxxx <949xxxxxx>)
;same => n,NoOp(CALLERID(all))
;same => n,set(calltime=${STRFTIME(${EPOCH},,%C%y-%m-%d+%H:%M:%S)})
;same => n,MixMonitor(/var/lib/asterisk/recordings/inside/${calltime}.-.${CALLERID(num)}-${EXTEN}.wav,b)
same => n,DBdeltree(lastcallerout)
same => n,set(DB(lastcallerout/lastcallerout)=${EXTEN})
same => n,Dial(PJSIP/Movistar_endpoint/sip:${EXTEN}@telefonica.net:5070,60)
same => n,1,Hangup(21)
This is the content of default/extensions.conf:
; Note: this file has been modified from the Asterisk defaults for the add-on
[general]
static=yes
[default]
include => parkedcalls
;
exten => 444,1,Park(,s)
;
exten => 555,1,ParkedCall(default,701)
;
exten => _X!,1,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})})
;
;extension for dialing chan_sip devices.
;exten => _X!,1,Dial(SIP/${EXTEN})
[parkedcallstimeout]
exten => s,1,Hangup()
However, if I issue a dialplan show
command, this is what I see in the output:
[ Context '__func_periodic_hook_context__' created by 'func_periodic_hook' ]
'beep' (CID match '') => 1. Answer() [func_periodic_hook]
2. Playback(beep) [func_periodic_hook]
'hook' (CID match '') => 1. Set(EncodedChannel=${CUT(HOOK_CHANNEL,-,1-2)}) [func_periodic_hook]
2. Set(GROUP_NAME=${EncodedChannel}${HOOK_ID}) [func_periodic_hook]
3. Set(GROUP(periodic-hook)=${GROUP_NAME}) [func_periodic_hook]
4. ExecIf($[${GROUP_COUNT(${GROUP_NAME}@periodic-hook)} > 1]?Hangup()) [func_periodic_hook]
5. Set(ChannelToSpy=${URIDECODE(${EncodedChannel})}) [func_periodic_hook]
6. ChanSpy(${ChannelToSpy},qEB) [func_periodic_hook]
[ Context 'parkedcalls' created by 'res_parking' ]
'700' => 1. Park() [res_parking]
'701' => 1. ParkedCall(default,701) [res_parking/default]
'702' => 1. ParkedCall(default,702) [res_parking/default]
'703' => 1. ParkedCall(default,703) [res_parking/default]
[ Context 'ael-builtin-h-bubble' created by 'pbx_ael' ]
'h' => 1. Goto(9991) [pbx_ael]
9991. Set(~~parentcxt~~=${STACK_PEEK(1,c,1)}) [pbx_ael]
9992. GotoIf($["${~~parentcxt~~}"=""]?9996) [pbx_ael]
9993. GotoIf(${DIALPLAN_EXISTS(${~~parentcxt~~},h,1)}?9994:9996) [pbx_ael]
9994. StackPop() [pbx_ael]
9995. Goto(${~~parentcxt~~},h,1) [pbx_ael]
9996. NoOp() [pbx_ael]
[ Context 'ael-default' created by 'pbx_ael' ]
Include => 'ael-demo' [pbx_ael]
[ Context 'ael-demo' created by 'pbx_ael' ]
'#' => 1. Playback(demo-thanks) [pbx_ael]
2. Hangup() [pbx_ael]
'1000' => 1. Goto(ael-default,s,1) [pbx_ael]
'2' => 1. Background(demo-moreinfo) [pbx_ael]
2. Goto(s,instructions) [pbx_ael]
'3' => 1. Set(LANGUAGE()=fr) [pbx_ael]
2. Goto(s,restart) [pbx_ael]
'500' => 1. Playback(demo-abouttotry) [pbx_ael]
2. Dial(IAX2/guest@misery.digium.com/s@default) [pbx_ael]
3. Playback(demo-nogo) [pbx_ael]
4. Goto(s,instructions) [pbx_ael]
'600' => 1. Playback(demo-echotest) [pbx_ael]
2. Echo() [pbx_ael]
3. Playback(demo-echodone) [pbx_ael]
4. Goto(s,instructions) [pbx_ael]
'8500' => 1. VoicemailMain() [pbx_ael]
2. Goto(s,instructions) [pbx_ael]
'i' => 1. Playback(invalid) [pbx_ael]
's' => 1. Wait(1) [pbx_ael]
2. Answer() [pbx_ael]
3. Set(TIMEOUT(digit)=5) [pbx_ael]
4. Set(TIMEOUT(response)=10) [pbx_ael]
[restart] 5. Background(demo-congrats) [pbx_ael]
[instructions] 6. MSet(x=$[0]) [pbx_ael]
7. GotoIf($[ ${x} < 3]?8:12) [pbx_ael]
8. Background(demo-instruct) [pbx_ael]
9. WaitExten() [pbx_ael]
10. MSet(x=$[${x} + 1]) [pbx_ael]
11. Goto(7) [pbx_ael]
12. NoOp(Finish for_ael-demo_3) [pbx_ael]
't' => 1. Goto(#,1) [pbx_ael]
'_1234' => 1. Gosub(ael-std-exten-ael,~~s~~,1(${EXTEN}, "IAX2")) [pbx_ael]
[ Context 'ael-std-exten-ael' created by 'pbx_ael' ]
'a' => 1. VoiceMailMain(${ext}) [pbx_ael]
2. Return() [pbx_ael]
'sw_1_' => 10. Goto(sw_1_.,10) [pbx_ael]
'sw_1_BUSY' => 10. Voicemail(${ext},b) [pbx_ael]
11. Goto(~~s~~,7) [pbx_ael]
'~~s~~' => 1. MSet(LOCAL(ext)=${ARG1}) [pbx_ael]
2. MSet(LOCAL(dev)=${ARG2}) [pbx_ael]
3. MSet(LOCAL(~~EXTEN~~)=${EXTEN}) [pbx_ael]
4. MSet(LOCAL(~~EXTEN~~)=${~~EXTEN~~}) [pbx_ael]
5. Dial(${dev}/${ext},20) [pbx_ael]
6. Goto(sw_1_${DIALSTATUS},10) [pbx_ael]
7. NoOp(Finish switch_ael-std-exten-ael_1) [pbx_ael]
8. Return() [pbx_ael]
'_sw_1_.' => 10. Voicemail(${ext},u) [pbx_ael]
11. Goto(~~s~~,7) [pbx_ael]
Include => 'ael-builtin-h-bubble' [pbx_ael]
[ Context 'ael-local' created by 'pbx_ael' ]
Include => 'ael-default' [pbx_ael]
Include => 'ael-trunklocal' [pbx_ael]
Include => 'ael-iaxtel700' [pbx_ael]
Include => 'ael-trunktollfree' [pbx_ael]
Include => 'ael-iaxprovider' [pbx_ael]
Ignore pattern => '9' [pbx_ael]
[ Context 'ael-longdistance' created by 'pbx_ael' ]
Include => 'ael-local' [pbx_ael]
Include => 'ael-trunkld' [pbx_ael]
Ignore pattern => '9' [pbx_ael]
[ Context 'ael-international' created by 'pbx_ael' ]
Include => 'ael-longdistance' [pbx_ael]
Include => 'ael-trunkint' [pbx_ael]
Ignore pattern => '9' [pbx_ael]
[ Context 'ael-trunktollfree' created by 'pbx_ael' ]
'_91800NXXXXXX' => 1. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
'_91866NXXXXXX' => 1. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
'_91877NXXXXXX' => 1. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
'_91888NXXXXXX' => 1. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
[ Context 'ael-trunklocal' created by 'pbx_ael' ]
'_9NXXXXXX' => 1. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
[ Context 'ael-trunkld' created by 'pbx_ael' ]
'_91NXXNXXXXXX' => 1. Gosub(ael-dundi-e164,~~s~~,1(${EXTEN:1})) [pbx_ael]
2. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
Include => 'ael-dundi-e164-lookup' [pbx_ael]
[ Context 'ael-trunkint' created by 'pbx_ael' ]
'_9011.' => 1. Gosub(ael-dundi-e164,~~s~~,1(${EXTEN:4})) [pbx_ael]
2. Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}}) [pbx_ael]
Include => 'ael-dundi-e164-lookup' [pbx_ael]
[ Context 'ael-iaxprovider' created by 'pbx_ael' ]
[ Context 'ael-iaxtel700' created by 'pbx_ael' ]
'_91700XXXXXXX' => 1. Dial(IAX2/${IAXINFO-AEL}@iaxtel.com/${EXTEN:1}@iaxtel) [pbx_ael]
[ Context 'ael-dundi-e164' created by 'pbx_ael' ]
'~~s~~' => 1. MSet(LOCAL(exten)=${ARG1}) [pbx_ael]
2. Goto(${exten},1) [pbx_ael]
3. Return() [pbx_ael]
Include => 'ael-builtin-h-bubble' [pbx_ael]
[ Context 'ael-dundi-e164-lookup' created by 'pbx_ael' ]
Include => 'ael-dundi-e164-local' [pbx_ael]
Include => 'ael-dundi-e164-switch' [pbx_ael]
[ Context 'ael-dundi-e164-switch' created by 'pbx_ael' ]
Alt. Switch => 'DUNDi/e164' [pbx_ael]
[ Context 'ael-dundi-e164-local' created by 'pbx_ael' ]
Include => 'ael-dundi-e164-canonical' [pbx_ael]
Include => 'ael-dundi-e164-customers' [pbx_ael]
Include => 'ael-dundi-e164-via-pstn' [pbx_ael]
[ Context 'ael-dundi-e164-via-pstn' created by 'pbx_ael' ]
[ Context 'ael-dundi-e164-customers' created by 'pbx_ael' ]
[ Context 'ael-dundi-e164-canonical' created by 'pbx_ael' ]
[ Context 'default' created by 'pbx_config' ]
'_[67]XXXXXXXX' => 1. NoOP(Llamadas a moviles) [extensions.conf:9]
2. set(PJSIP/Movistar_endpoint, ${CALLERID(all)}) [extensions.conf:10]
3. DBdeltree(lastcallerout) [extensions.conf:16]
4. set(DB(lastcallerout/lastcallerout)=${EXTEN}) [extensions.conf:17]
5. Dial(PJSIP/Movistar_endpoint/sip:${EXTEN}@telefonica.net:5070,60) [extensions.conf:18]
6. 1,Hangup(21) [extensions.conf:19]
-= 33 extensions (85 priorities) in 23 contexts. =-
Where is all this this info coming from? I'd rather to override any other dialplan info included in any file, so I can use my own dialplan only. This will help for the purpose of isolate the problem. I am saying this because it is strange that if I empty the custom/extensions.conf file and I make a call, the call is actually placed fine. Shouldn't it be rejected because there is not any dialplan in my custom/extensions.conf? I just want to make sure that all tests I am doing in my dialplan are taken into account by Asterisk, something I am not 100% sure now.
EDIT: By the way, I just realized that when Asterisk addon is restarted, the dialplan show
command does not display the contents of custom/extensions.conf
file. A dialplan reload command is necessary after restarting for the addon to display the content contained in custom/extensions.conf
. This is not the expected behaviour, isn't it?
Managed to sort this out with the assistance of the Asterisk forum. The problem was my dialplan and the syntax of the service call I was using to place the call. For anyones's reference, below is the final PJSIP config I have to place calls from my HASS+Asterisk AddOn to a mobile phone in Spain (as long as it starts either by 6 or 7. I think there is some content that can be cleaned up, but it works for the purpose. Up to anyone to optimize them as wished:
custom/pjsip.conf:
[general]
language=es
allowguest=no
autodomain=yes
domain=telefonica.net
sipdomain=telefonica.net
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
[endpoint_internal](!)
type=endpoint
context=home
direct_media=no
allow=g729
allow=ulaw
allow=alaw
allow=gsm
[auth_userpass](!)
type=auth
auth_type=userpass
[aor_dynamic](!)
type=aor
max_contacts=2
remove_existing=yes
[100](endpoint_internal)
auth=100
aors=100
mwi_from_user=100
[100](auth_userpass)
username=100
password=[PASSWORD]
[100](aor_dynamic)
[101](endpoint_internal)
auth=101
aors=101
mwi_from_user=101
[101](auth_userpass)
username=101
password=[PASSWORD]
[101](aor_dynamic)
[endpoint]
100rel=yes
[Movistar_reg]
type=registration
transport=transport-udp
outbound_auth=Movistar_auth
server_uri=sip:10.31.255.134:5070
client_uri=sip:949xxxxxx@telefonica.net
contact_user=949xxxxxx
retry_interval=60
expiration=3600
support_path=yes
[Movistar_auth]
type=auth
auth_type=userpass
password=949xxxxxx
username=949xxxxxx@telefonica.net
realm=telefonica.net
[Movistar_aor]
type=aor
max_contacts=2
contact=sip:949xxxxxx@telefonica.net
qualify_frequency=60
qualify_timeout=30
support_path=yes
;send_rpid=yes
;send_pai=yes
[Movistar_endpoint]
type=endpoint
transport=transport-udp
context=external-calls
disallow=all
allow=ulaw
allow=alaw
allow=gsm
allow=g729
outbound_auth=Movistar_auth
outbound_proxy=sip:10.31.255.134:5070\;lr
aors=Movistar_aor
from_user=949xxxxxx
from_domain=telefonica.net
callerid=asreceived
send_pai=yes
rewrite_contact=no
send_pai=yes
send_rpid=yes
[Movistar_identify]
type=identify
endpoint=Movistar_endpoint
match=10.31.255.134
custom/extensions.conf:
[general]
static=yes
writeprotect=yes
autofallthrough=yes
extenpatternmatchnew=yes
clearglobalvars=yes
[external-calls]
exten => _[67]XXXXXXXX,1,NoOP(Llamadas a moviles)
same => n,Set(CALLERID(all)=949xxxxxx <949xxxxxx>)
same => n,NoOp(CALLERID(all))
;same => n,set(calltime=${STRFTIME(${EPOCH},,%C%y-%m-%d+%H:%M:%S)})
;same => n,MixMonitor(/var/lib/asterisk/recordings/inside/${calltime}.-.${CALLERID(num)}-${EXTEN}.wav,b)
same => n,DBdeltree(lastcallerout)
same => n,set(DB(lastcallerout/lastcallerout)=${EXTEN})
same => n,Dial(PJSIP/Movistar_endpoint/sip:${EXTEN}@telefonica.net:5070,60)
same => n,1,Hangup(21)
Service call to make a phone call:
service: hassio.addon_stdin
data:
addon: 3e533915_asterisk
input: originate Local/686xxxxxx@external-calls application Playback tt-monkeys
Hope it helps to someone else. Cheers!
Just another quick question. Is it possible to connect to Asterisk through terminal so I can type commands directly and see the output on the fly, instead of having to send service calls on a per command basis?
https://tech7fox.github.io/sip-hass-docs/docs/add-on/troubleshooting#accessing-asterisk-cli
Where is all this this info coming from?
I'm not sure, maybe /default/extensions.ael
? Maybe @TECH7Fox knows better.
EDIT: By the way, I just realized that when Asterisk addon is restarted, the dialplan show command does not display the contents of custom/extensions.conf file. A dialplan reload command is necessary after restarting for the addon to display the content contained in custom/extensions.conf. This is not the expected behaviour, isn't it?
There must be something wrong at your side. Restarting the add-on definitely reloads the dialplans.
https://tech7fox.github.io/sip-hass-docs/docs/add-on/troubleshooting#accessing-asterisk-cli
Thank you! Will be definitely useful. Sorry for not noticing by myself. I've been reading a lot of information to solve my issue in the last few days and I feel a bit dizzy. :)
There must be something wrong at your side. Restarting the add-on definitely reloads the dialplans.
You are right. The dialplan is reloaded. However, for whatever reason (at least in my system) the dialplan show does not display it, but it definitely works as it was.
However, for whatever reason (at least in my system) the dialplan show does not display it, but it definitely works as it was.
Hm... I see. Maybe this is an Asterisk bug. I will try to upgrade Asterisk soon.
Maybe @TECH7Fox knows better.
No idea. Looks like some compiled version of the dialplan somewhere?
Hello,
This is not really an issue, but a kind request to get some help about an problem I have. I am trying to setup a trunk endpoint so I can make automated outbound calls upon my place's alarm triggering. My telco provider is Movistar (Spain). For reference, I have an ATA SIP device (Grandstream HT802) in the same network that it is working fine, so I guess the problem is not network related but some sort of misconfiguration about .conf custom files. I am not an Asterisk specialist. A couple of years ago I setup a FreePBX server from scratch following some tutorials, but that's something I am not going to win a prize for...
I have the Asterisk addon installed in my Home Assistant core-2023.7.3, the HACS SIP card and the integration. Everything is working fine when calling between HA persons. Basically, I followed this tutorial and everything was pretty straight forward because I already have an SSL certificate installed in my router for the HA domain name.
However, after setting up the trunk (I just need to make outbound calls for the purpose of warning upon my place alarm triggering), I get the following error from the addon log:
For the moment, I am just trying to receive the call on my cellphone with the "angry monkeys" sound.
The command I issue for this is:
This is the content of config/asterisk/custom/sip.conf:
And this is the content of config/asterisk/custom/extensions.conf
I masked sensitive information with an
x
(lowercase), but please do note that I have replaced every single digit accordingly, just in case any one wants to check whether the dialplan is ok or not. DialplanX
characters are uppercase to avoid confusion.I have spent several days trying to figure out by myself how to fix this so I can make a call, but I am not able to move forward from here.
I will be more than happy to give further feedback if needed. Thanks in advance!
Sésar