Hello Everyone,
I am using Asterisk 20.2.1 based addon in Home Assistant (a home automation software). Tried to ask for support to the addon developers but it seems they know a lot about the addon itself and the Asterisk implementation, but their knowledge about Asterisk itself is limited.
As far as I know, it works in the same way than a standard Asterisk system, but with small differences. The most important one is that .conf files must be edited in a custom folder where you have to put a copy of the main file. Then, both the main and custom files are loaded. Main .conf files shall not be edited. Another thing is that commands have to be issued from an addon stdin service call, that’s the reason you will see below that commands are stated in the following way:
[12:21:25] INFO: Executing command from stdin: asterisk -rx '[COMMAND]'
The purpose of using Asterisk for me is to be able to make outbound external calls to a cellphone number from such system. My telco company is Movistar Spain, which uses a SIP (not PJSIP) configuration on their devices. I tried to make Asterisk work with such a config but didn’t managed to do that, so decided to switch to PJSIP. Now, calls are received fine. However, the CALLERID info is not being received (or is not being received as the telco/phone expect), so the phone is displaying “Anonymous”. I think the LAN part is fine, because I have an ATA SIP device in my network (Grandstream HT802) with a SIP setup and external calls and callerid info are well received.
I have been reading around trying different options but no success for the moment (you will see in my config below some comma commented lines; that means that I tried them at some point), so I decided to ask for assistance here.
Ok, after this long introduction (sorry for that) these are my pjsip.conf, extensions.conf and command I issue to test the call:
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
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
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(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)
Command issued for testing:
originate PJSIP/Movistar_endpoint/sip:686xxxxxx@telefonica.net:5070 application Playback tt-monkeys
Endpoint info:
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
I/OAuth: <AuthId/UserName...........................................................>
Aor: <Aor............................................> <MaxContact>
Contact: <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
Transport: <TransportId........> <Type> <cos> <tos> <BindAddress..................>
Identify: <Identify/Endpoint.........................................................>
Match: <criteria.........................>
Channel: <ChannelId......................................> <State.....> <Time.....>
Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......>
==========================================================================================
Endpoint: Movistar_endpoint Unavailable 0 of inf
OutAuth: Movistar_auth/949xxxxxx@telefonica.net
Aor: Movistar_aor 2
Contact: Movistar_aor/sip:949xxxxxx@telefonica.net 9def89a196 Unavail nan
Transport: transport-udp udp 0 0 0.0.0.0:5060
Identify: Movistar_identify/Movistar_endpoint
Match: 10.31.255.134/32
ParameterName : ParameterValue
===================================================================================================
100rel : yes
accept_multiple_sdp_answers : false
accountcode :
acl :
aggregate_mwi : true
allow : (ulaw|alaw|gsm|g729)
allow_overlap : true
allow_subscribe : true
allow_transfer : true
allow_unauthenticated_options : false
aors : Movistar_aor
asymmetric_rtp_codec : false
auth :
bind_rtp_to_media_address : false
bundle : false
call_group :
callerid : asreceived
callerid_privacy : allowed_not_screened
callerid_tag :
codec_prefs_incoming_answer : prefer:pending, operation:intersect, keep:all, transcode:allow
codec_prefs_incoming_offer : prefer:pending, operation:intersect, keep:all, transcode:allow
[Jul 27 12:20:40] e[1;30m -- e[0mRemote UNIX connection disconnected
codec_prefs_outgoing_answer : prefer:pending, operation:intersect, keep:all, transcode:allow
codec_prefs_outgoing_offer : prefer:pending, operation:union, keep:all, transcode:allow
connected_line_method : invite
contact_acl :
context : external-calls
cos_audio : 0
cos_video : 0
device_state_busy_at : 0
direct_media : true
direct_media_glare_mitigation : none
direct_media_method : invite
disable_direct_media_on_nat : false
dtls_auto_generate_cert : No
dtls_ca_file :
dtls_ca_path :
dtls_cert_file :
dtls_cipher :
dtls_fingerprint : SHA-256
dtls_private_key :
dtls_rekey : 0
dtls_setup : active
dtls_verify : No
dtmf_mode : rfc4733
fax_detect : false
fax_detect_timeout : 0
follow_early_media_fork : true
force_avp : false
force_rport : true
from_domain : telefonica.net
from_user : 949xxxxxx
g726_non_standard : false
geoloc_incoming_call_profile :
geoloc_outgoing_call_profile :
ice_support : false
identify_by : username,ip
ignore_183_without_sdp : false
inband_progress : false
incoming_call_offer_pref : local
incoming_mwi_mailbox :
language :
mailboxes :
max_audio_streams : 1
max_video_streams : 1
media_address :
media_encryption : no
media_encryption_optimistic : false
media_use_received_transport : false
message_context :
moh_passthrough : false
moh_suggest : default
mwi_from_user :
mwi_subscribe_replaces_unsolicited : no
named_call_group :
named_pickup_group :
notify_early_inuse_ringing : false
one_touch_recording : false
outbound_auth : Movistar_auth
outbound_proxy :
outgoing_call_offer_pref : remote_merge
overlap_context :
pickup_group :
preferred_codec_only : false
record_off_feature : automixmon
record_on_feature : automixmon
refer_blind_progress : true
rewrite_contact : false
rpid_immediate : false
rtcp_mux : false
rtp_engine : asterisk
rtp_ipv6 : false
rtp_keepalive : 0
rtp_symmetric : false
rtp_timeout : 0
rtp_timeout_hold : 0
sdp_owner : -
sdp_session : Asterisk
send_aoc : false
send_connected_line : yes
send_diversion : true
send_history_info : false
send_pai : true
send_rpid : true
set_var :
srtp_tag_32 : false
stir_shaken : off
stir_shaken_profile :
sub_min_expiry : 0
subscribe_context :
suppress_q850_reason_headers : false
t38_bind_udptl_to_media_address : false
t38_udptl : false
t38_udptl_ec : none
t38_udptl_ipv6 : false
t38_udptl_maxdatagram : 0
t38_udptl_nat : false
timers : yes
timers_min_se : 90
timers_sess_expires : 1800
tone_zone :
tos_audio : 0
tos_video : 0
transport : transport-udp
trust_connected_line : yes
trust_id_inbound : false
trust_id_outbound : false
use_avpf : false
use_ptime : false
user_eq_phone : false
voicemail_extension :
webrtc : no
Asterisk ending (0).
I would love to be able to share traffic being generated by Asterisk, so I could filter From:
or similar headers. However, I don’t know how to do it.
What I can do is to share an INVITE log I got from the telco forum, although I am not sure whether it is valid for the purpose, because it is a SIP invite and from a post from 2018:
<--- SIP read from UDP:10.31.255.134:5070 --->
INVITE sip:918464574@192.168.1.140:5060 SIP/2.0
Via: SIP/2.0/UDP 10.31.255.134:5070;branch=z9hG4bKajpv6b001o7go8gef2o0.1
To: "34 91xxxxxx"<sip:91xxxxxx@telefonica.net>
**From: <sip:telefonica.net>;tag=2102388202-1524165979658-**
Call-ID: BW212619658190418-526927241@192.168.126.12
CSeq: 800036614 INVITE
Max-Forwards: 68
Content-Length: 149
**Contact: <sip:10.31.255.134:5070;endpoint=192.168.126.12;transport=udp>**
Content-Type: application/sdp
Allow: ACK, BYE, CANCEL, INFO, INVITE, OPTIONS, PRACK, REFER, NOTIFY, UPDATE
Accept: application/media_control+xml
Accept: application/sdp
Accept: multipart/mixed
Supported: timer
P-Asserted-Identity: <sip:+34xxxxxx@telefonica.net;user=phone>
Privacy: none
Min-SE: 180
Session-Expires: 600
P-Called-Party-ID: <sip:91xxxxxx@telefonica.net>
Recv-Info: x-broadworks-client-session-info
v=0
o=BroadWorks 29794631 1 IN IP4 10.31.255.135
s=-
c=IN IP4 10.31.255.135
t=0 0
m=audio 15910 RTP/AVP 8 18
a=fmtp:18 annexb=yes
a=ptime:20
I am not an Asterisk specialist… actually, it has been quite hard to reach the point I am at, but I don’t know how to move forward. Any idea on how to fix this, please?