PJSIP external calls not displaying CALLERID with Movistar Spain

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?

The posted SIP trace you’ve found is an incoming call, not an outgoing call. You’d need to provide an actual outgoing trace, and also state how they are expecting CID to be sent to them.

Thank you so much for looking at my problem!

This is the log extracted from the ATA SIP device that I have in my place, the one that connects over SIP and which works fine. I took a part where I made a call to number 686xxxxxx from my local number 949xxxxxx. I hope it works for the purpose of knowing what my telco is expecting to get:

HT802 --- 2023-07-27 15:19:38.057 SENDING TO 10.31.255.134:5070
REGISTER sip:telefonica.net SIP/2.0
Via: SIP/2.0/UDP 192.168.0.8:5060;branch=z9hG4bK1315552501;rport
Route: <sip:10.31.255.134:5070;lr>
From: "949xxxxxx" <sip:949xxxxxx@telefonica.net>;tag=1389006728
To: <sip:949xxxxxx@telefonica.net>
Call-ID: 764828959-5060-1@BJC.BGI.A.I
CSeq: 4061 REGISTER
Contact: <sip:949xxxxxx@192.168.0.8:5060>
Max-Forwards: 70
User-Agent: Grandstream HT802 1.0.45.2
Supported: path
Expires: 3600
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE
Content-Length: 0

HT802 --- 2023-07-27 15:19:38.069 RECEIVING FROM 10.31.255.134:5070
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.8:5060;received=10.29.1.241;branch=z9hG4bK1315552501;rport=1024
From: "949xxxxxx" <sip:949xxxxxx@telefonica.net>;tag=1389006728
To: <sip:949xxxxxx@telefonica.net>;tag=aprqv2ii1gecd3pa6-jfds1f000o3qd
Call-ID: 764828959-5060-1@BJC.BGI.A.I
CSeq: 4061 REGISTER
P-Associated-URI: <sip:949xxxxxx@telefonica.net>
P-Associated-URI: <tel:+34949xxxxxx>
P-Associated-URI: <sip:f2018009635772_1@telefonica.net>
Contact: <sip:949xxxxxx@10.29.3.206:5060;transport=udp>;expires=1505
Contact: <sip:949xxxxxx@192.168.0.100:5060>;expires=3262
Contact: <sip:949xxxxxx@192.168.0.8:5060>;expires=70
Service-Route: <sip:949xxxxxx@10.31.255.134:5070;transport=udp;lr>
Content-Length: 0

HT802 --- 2023-07-27 15:19:38.982 RECEIVING FROM 178.62.11.219:42324
REGISTER sip:333@[MY_WAN_IP] SIP/2.0
To: 333 <sip:333@[MY_WAN_IP]>
From:  <sip:333@[MY_WAN_IP]>;tag=0c26cd11
Via: SIP/2.0/UDP [MY_WAN_IP]:42324;branch=w7tjotx69jlp5gvnhr5lsmdfv53wcyogij34ir2cy0td8vj012096n6gevcks029aznjbyz;rport
Call-ID: 3cd472b5181ed3343a73c8b86697be4d
CSeq: 1 REGISTER
Contact: <sip:333@[MY_WAN_IP]:42324>
User-Agent: 
Max-forwards: 70
Allow: INVITE, ACK, CANCEL, BYE, REFER
Content-Type: application/sdp


HT802 --- 2023-07-27 15:19:43.629 RECEIVING FROM 97.64.97.250:35277
REGISTER sip:303@[MY_WAN_IP] SIP/2.0
To: 303 <sip:303@[MY_WAN_IP]>
From:  <sip:303@[MY_WAN_IP]>;tag=0c26cd11
Via: SIP/2.0/UDP [MY_WAN_IP]:35277;branch=mqw6ift0cv2ct2v1dar9zgzaxua8us1hmu9qfv85wb0oi7ir8951zfxzy1ngawy6xqumxyl;rport
Call-ID: 8b9836ef9f8da26ef073e6e0f0ae88bc
CSeq: 1 REGISTER
Contact: <sip:303@[MY_WAN_IP]:35277>
User-Agent: 
Max-forwards: 70
Allow: INVITE, ACK, CANCEL, BYE, REFER
Content-Type: application/sdp


HT802 --- 2023-07-27 15:19:47.646 RECEIVING FROM 20.90.177.230:50586
REGISTER sip:1022@[MY_WAN_IP] SIP/2.0
To: 1022 <sip:1022@[MY_WAN_IP]>
From:  <sip:1022@[MY_WAN_IP]>;tag=0c26cd11
Via: SIP/2.0/UDP [MY_WAN_IP]:50586;branch=4hs0ah4xg7p9g4qqynvtmnd0c5mkhzrfs6tki7ys35n6g0lijoug8ela1zl51evjsxpfw7g;rport
Call-ID: d550e23cfadff5d97b3a080a34720672
CSeq: 1 REGISTER
Contact: <sip:1022@[MY_WAN_IP]:50586>
User-Agent: 
Max-forwards: 70
Allow: INVITE, ACK, CANCEL, BYE, REFER
Content-Type: application/sdp


HT802 --- 2023-07-27 15:19:51.984 RECEIVING FROM 20.90.106.198:42120
REGISTER sip:010@[MY_WAN_IP] SIP/2.0
To: 010 <sip:010@[MY_WAN_IP]>
From:  <sip:010@[MY_WAN_IP]>;tag=0c26cd11
Via: SIP/2.0/UDP [MY_WAN_IP]:42120;branch=oduoys93sv2dhb6xet3389f38fvxudosizv82fe2rvk1xtvpswjuf3ivthfawaphtzptkc2;rport
Call-ID: 16044d7d4672f2cbf6aa71dedbb3c02f
CSeq: 1 REGISTER
Contact: <sip:010@[MY_WAN_IP]:42120>
User-Agent: 
Max-forwards: 70
Allow: INVITE, ACK, CANCEL, BYE, REFER
Content-Type: application/sdp


HT802 --- 2023-07-27 15:19:54.269 SENDING TO 10.31.255.134:5070
INVITE sip:686xxxxxx@telefonica.net SIP/2.0
Via: SIP/2.0/UDP 192.168.0.8:5060;branch=z9hG4bK1543780400;rport
Route: <sip:10.31.255.134:5070;lr>
From: "949xxxxxx" <sip:949xxxxxx@telefonica.net>;tag=944191479
To: <sip:686xxxxxx@telefonica.net>
Call-ID: 691093267-5060-4@BJC.BGI.A.I
CSeq: 30 INVITE
Contact: "949xxxxxx" <sip:949xxxxxx@192.168.0.8:5060>
Max-Forwards: 70
User-Agent: Grandstream HT802 1.0.45.2
Privacy: none
P-Preferred-Identity: "949xxxxxx" <sip:949xxxxxx@telefonica.net>
P-Access-Network-Info: IEEE-EUI-48;eui-48-addr=08-62-66-92-B5-98
P-Emergency-Info: IEEE-EUI-48;eui-48-addr=00-0B-82-C3-CE-80
Supported: replaces, path, timer, eventlist
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE
Content-Type: application/sdp
Accept: application/sdp, application/dtmf-relay
Content-Length:   479

v=0
o=949xxxxxx 8000 8000 IN IP4 192.168.0.8
s=SIP Call
c=IN IP4 192.168.0.8
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 2 97 123 9 101
a=sendrecv
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:2 G726-32/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=20
a=rtpmap:123 opus/48000/2
a=fmtp:123 maxplaybackrate=16000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16,32-36,54


HT802 --- 2023-07-27 15:19:54.283 RECEIVING FROM 10.31.255.134:5070
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.0.8:5060;received=10.29.1.241;branch=z9hG4bK1543780400;rport=1024
From: "949xxxxxx" <sip:949xxxxxx@telefonica.net>;tag=944191479
To: <sip:686xxxxxx@telefonica.net>
Call-ID: 691093267-5060-4@BJC.BGI.A.I
CSeq: 30 INVITE
Content-Length: 0

As for the outgoing trace from my Asterisk instance, this is what I can see after enabling PJSIP debug with pjsip set logger on command:

[Jul 27 15:38:56] <--- Transmitting SIP request (1067 bytes) to UDP:10.31.255.134:5070 --->
[Jul 27 15:38:56] INVITE sip:686xxxxxx@telefonica.net:5070 SIP/2.0
[Jul 27 15:38:56] Via: SIP/2.0/UDP 192.168.0.100:5060;rport;branch=z9hG4bKPj9835cd52-f58e-4bb3-8638-ce49c476b745
[Jul 27 15:38:56] From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=8aab90b0-5920-446b-8b0e-a2e078fc988d
[Jul 27 15:38:56] To: <sip:686xxxxxx@telefonica.net>
[Jul 27 15:38:56] Contact: <sip:asterisk@192.168.0.100:5060>
[Jul 27 15:38:56] Call-ID: 4b86e96f-2fd0-464c-8df8-56e89774f577
[Jul 27 15:38:56] CSeq: 15587 INVITE
[Jul 27 15:38:56] Route: <sip:10.31.255.134:5070;lr>
[Jul 27 15:38:56] Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
[Jul 27 15:38:56] Supported: 100rel, timer, replaces, norefersub, histinfo
[Jul 27 15:38:56] Session-Expires: 1800
[Jul 27 15:38:56] Min-SE: 90
[Jul 27 15:38:56] Max-Forwards: 70
[Jul 27 15:38:56] User-Agent: Asterisk PBX 20.2.1
[Jul 27 15:38:56] Content-Type: application/sdp
[Jul 27 15:38:56] Content-Length:   333
[Jul 27 15:38:56] 
[Jul 27 15:38:56] v=0
[Jul 27 15:38:56] o=- 1652535652 1652535652 IN IP4 192.168.0.100
[Jul 27 15:38:56] s=Asterisk
[Jul 27 15:38:56] c=IN IP4 192.168.0.100
[Jul 27 15:38:56] t=0 0
[Jul 27 15:38:56] m=audio 13450 RTP/AVP 0 8 3 18 101
[Jul 27 15:38:56] a=rtpmap:0 PCMU/8000
[Jul 27 15:38:56] a=rtpmap:8 PCMA/8000
[Jul 27 15:38:56] a=rtpmap:3 GSM/8000
[Jul 27 15:38:56] a=rtpmap:18 G729/8000
[Jul 27 15:38:56] a=fmtp:18 annexb=no
[Jul 27 15:38:56] a=rtpmap:101 telephone-event/8000
[Jul 27 15:38:56] a=fmtp:101 0-16
[Jul 27 15:38:56] a=ptime:20
[Jul 27 15:38:56] a=maxptime:150
[Jul 27 15:38:56] a=sendrecv
[Jul 27 15:38:56] 
[Jul 27 15:38:56] <--- Received SIP response (360 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:38:56] SIP/2.0 100 Trying
[Jul 27 15:38:56] Via: SIP/2.0/UDP 192.168.0.100:5060;received=10.29.1.241;branch=z9hG4bKPj9835cd52-f58e-4bb3-8638-ce49c476b745;rport=5060
[Jul 27 15:38:56] From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=8aab90b0-5920-446b-8b0e-a2e078fc988d
[Jul 27 15:38:56] To: <sip:686xxxxxx@telefonica.net>
[Jul 27 15:38:56] Call-ID: 4b86e96f-2fd0-464c-8df8-56e89774f577
[Jul 27 15:38:56] CSeq: 15587 INVITE
[Jul 27 15:38:56] Content-Length: 0
[Jul 27 15:38:56] 
[Jul 27 15:38:56] 
[Jul 27 15:38:57] <--- Received SIP response (565 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:38:57] SIP/2.0 183 Session Progress
[Jul 27 15:38:57] Via: SIP/2.0/UDP 192.168.0.100:5060;received=10.29.1.241;branch=z9hG4bKPj9835cd52-f58e-4bb3-8638-ce49c476b745;rport=5060
[Jul 27 15:38:57] From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=8aab90b0-5920-446b-8b0e-a2e078fc988d
[Jul 27 15:38:57] To: <sip:686xxxxxx@telefonica.net>;tag=16335917-1690465137350
[Jul 27 15:38:57] Call-ID: 4b86e96f-2fd0-464c-8df8-56e89774f577
[Jul 27 15:38:57] CSeq: 15587 INVITE
[Jul 27 15:38:57] Content-Length: 0
[Jul 27 15:38:57] Contact: <sip:10.31.255.134:5070;endpoint=172.24.62.103;transport=udp>
[Jul 27 15:38:57] Allow: ACK, BYE, CANCEL, INFO, INVITE, OPTIONS, PRACK, REFER, NOTIFY, UPDATE
[Jul 27 15:38:57] Supported: timer
[Jul 27 15:38:57] 
[Jul 27 15:38:57] 
[Jul 27 15:38:57] e[1;30m    -- e[0mPJSIP/Movistar_endpoint-00000000 is making progress
[Jul 27 15:38:57] <--- Received SIP response (556 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:38:57] SIP/2.0 180 Ringing
[Jul 27 15:38:57] Via: SIP/2.0/UDP 192.168.0.100:5060;received=10.29.1.241;branch=z9hG4bKPj9835cd52-f58e-4bb3-8638-ce49c476b745;rport=5060
[Jul 27 15:38:57] From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=8aab90b0-5920-446b-8b0e-a2e078fc988d
[Jul 27 15:38:57] To: <sip:686xxxxxx@telefonica.net>;tag=16335917-1690465137350
[Jul 27 15:38:57] Call-ID: 4b86e96f-2fd0-464c-8df8-56e89774f577
[Jul 27 15:38:57] CSeq: 15587 INVITE
[Jul 27 15:38:57] Content-Length: 0
[Jul 27 15:38:57] Contact: <sip:10.31.255.134:5070;endpoint=172.24.62.103;transport=udp>
[Jul 27 15:38:57] Allow: ACK, BYE, CANCEL, INFO, INVITE, OPTIONS, PRACK, REFER, NOTIFY, UPDATE
[Jul 27 15:38:57] Supported: timer
[Jul 27 15:38:57] 
[Jul 27 15:38:57] 
[Jul 27 15:38:57] e[1;30m    -- e[0mPJSIP/Movistar_endpoint-00000000 is ringing
[Jul 27 15:38:58] <--- Transmitting SIP request (511 bytes) to UDP:10.31.255.134:5070 --->
[Jul 27 15:38:58] OPTIONS sip:949xxxxxx@telefonica.net SIP/2.0
[Jul 27 15:38:58] Via: SIP/2.0/UDP 192.168.0.100:5060;rport;branch=z9hG4bKPjb3d6cd31-c0f4-4d13-8d53-dae969bfbd49
[Jul 27 15:38:58] From: <sip:Movistar_endpoint@192.168.0.100>;tag=8ecbd4d9-7eeb-4a26-8e6e-415a2c57b49c
[Jul 27 15:38:58] To: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:38:58] Contact: <sip:Movistar_endpoint@192.168.0.100:5060>
[Jul 27 15:38:58] Call-ID: 0385ded3-0408-4be8-8f6a-2c168a275998
[Jul 27 15:38:58] CSeq: 33601 OPTIONS
[Jul 27 15:38:58] Route: <sip:10.31.255.134:5070;lr>
[Jul 27 15:38:58] Supported: path
[Jul 27 15:38:58] Max-Forwards: 70
[Jul 27 15:38:58] User-Agent: Asterisk PBX 20.2.1
[Jul 27 15:38:58] Content-Length:  0
[Jul 27 15:38:58] 
[Jul 27 15:38:58] 
[Jul 27 15:38:58] <--- Received SIP request (656 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:38:58] OPTIONS sip:949xxxxxx@192.168.0.100:5060 SIP/2.0
[Jul 27 15:38:58] Via: SIP/2.0/UDP 10.31.255.134:5070;branch=z9hG4bKmn9d8e009g5qhng65fm0.1
[Jul 27 15:38:58] To: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:38:58] From: <sip:Movistar_endpoint@192.168.0.100>;tag=8ecbd4d9-7eeb-4a26-8e6e-415a2c57b49c
[Jul 27 15:38:58] Call-ID: 0385ded3-0408-4be8-8f6a-2c168a275998
[Jul 27 15:38:58] CSeq: 33601 OPTIONS
[Jul 27 15:38:58] Max-Forwards: 65
[Jul 27 15:38:58] Content-Length: 0
[Jul 27 15:38:58] Contact: <sip:949xxxxxx@10.31.255.134:5070;endpoint=192.168.0.100:5060;firewall=10.29.1.241;transport=udp>
[Jul 27 15:38:58] Supported: path
[Jul 27 15:38:58] P-Asserted-Identity: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:38:58] P-Asserted-Identity: <tel:+34949xxxxxx>
[Jul 27 15:38:58] User-Agent: Asterisk PBX 20.2.1
[Jul 27 15:38:58] P-Called-Party-ID: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:38:58] 
[Jul 27 15:38:58] 
[Jul 27 15:38:58] <--- Transmitting SIP response (891 bytes) to UDP:10.31.255.134:5070 --->
[Jul 27 15:38:58] SIP/2.0 404 Not Found
[Jul 27 15:38:58] Via: SIP/2.0/UDP 10.31.255.134:5070;rport=5070;received=10.31.255.134;branch=z9hG4bKmn9d8e009g5qhng65fm0.1
[Jul 27 15:38:58] Call-ID: 0385ded3-0408-4be8-8f6a-2c168a275998
[Jul 27 15:38:58] From: <sip:Movistar_endpoint@192.168.0.100>;tag=8ecbd4d9-7eeb-4a26-8e6e-415a2c57b49c
[Jul 27 15:38:58] To: <sip:949xxxxxx@telefonica.net>;tag=z9hG4bKmn9d8e009g5qhng65fm0.1
[Jul 27 15:38:58] CSeq: 33601 OPTIONS
[Jul 27 15:38:58] Accept: application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, application/dialog-info+xml, application/pidf+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/sdp, message/sipfrag;version=2.0
[Jul 27 15:38:58] Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
[Jul 27 15:38:58] Supported: 100rel, timer, replaces, norefersub
[Jul 27 15:38:58] Accept-Encoding: identity
[Jul 27 15:38:58] Accept-Language: en
[Jul 27 15:38:58] Server: Asterisk PBX 20.2.1
[Jul 27 15:38:58] Content-Length:  0
[Jul 27 15:38:58] 
[Jul 27 15:38:58] 
[Jul 27 15:38:58] <--- Received SIP response (909 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:38:58] SIP/2.0 200 OK
[Jul 27 15:38:58] Via: SIP/2.0/UDP 192.168.0.100:5060;received=10.29.1.241;branch=z9hG4bKPjb3d6cd31-c0f4-4d13-8d53-dae969bfbd49;rport=5060
[Jul 27 15:38:58] From: <sip:Movistar_endpoint@192.168.0.100>;tag=8ecbd4d9-7eeb-4a26-8e6e-415a2c57b49c
[Jul 27 15:38:58] To: <sip:949xxxxxx@telefonica.net>;tag=sn44pzks
[Jul 27 15:38:58] Call-ID: 0385ded3-0408-4be8-8f6a-2c168a275998
[Jul 27 15:38:58] CSeq: 33601 OPTIONS
[Jul 27 15:38:58] Content-Length: 242
[Jul 27 15:38:58] Content-Type: application/sdp
[Jul 27 15:38:58] Accept: application/sdp
[Jul 27 15:38:58] Supported: 100rel, replaces, timer, privacy, in-dialog
[Jul 27 15:38:58] P-Asserted-Identity: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:38:58] P-Asserted-Identity: <tel:+34949xxxxxx>
[Jul 27 15:38:58] Session-ID: 633169337a33306c69636d7a3833636d
[Jul 27 15:38:58] User-Agent: HUAWEI-EchoLife HG8240H/V3R017C10S201
[Jul 27 15:38:58] 
[Jul 27 15:38:58] v=0
[Jul 27 15:38:58] o=huawei 73 1 IN IP4 10.31.255.134
[Jul 27 15:38:58] s=-
[Jul 27 15:38:58] c=IN IP4 10.31.255.134
[Jul 27 15:38:58] t=0 0
[Jul 27 15:38:58] m=audio 0 RTP/AVP 8 0 18 9 96
[Jul 27 15:38:58] a=rtpmap:8 PCMA/8000
[Jul 27 15:38:58] a=rtpmap:0 PCMU/8000
[Jul 27 15:38:58] a=rtpmap:18 G729/8000
[Jul 27 15:38:58] a=rtpmap:9 G722/8000
[Jul 27 15:38:58] a=rtpmap:96 RED/8000/1
[Jul 27 15:38:58] m=image 0 udptl t38
[Jul 27 15:38:58] 
[Jul 27 15:39:00] <--- Received SIP response (390 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:39:00] SIP/2.0 486 Busy here
[Jul 27 15:39:00] Via: SIP/2.0/UDP 192.168.0.100:5060;received=10.29.1.241;branch=z9hG4bKPj9835cd52-f58e-4bb3-8638-ce49c476b745;rport=5060
[Jul 27 15:39:00] From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=8aab90b0-5920-446b-8b0e-a2e078fc988d
[Jul 27 15:39:00] To: <sip:686xxxxxx@telefonica.net>;tag=16335917-1690465137350
[Jul 27 15:39:00] Call-ID: 4b86e96f-2fd0-464c-8df8-56e89774f577
[Jul 27 15:39:00] CSeq: 15587 INVITE
[Jul 27 15:39:00] Content-Length: 0
[Jul 27 15:39:00] 
[Jul 27 15:39:00] 
[Jul 27 15:39:00] <--- Transmitting SIP request (473 bytes) to UDP:10.31.255.134:5070 --->
[Jul 27 15:39:00] ACK sip:686xxxxxx@telefonica.net:5070 SIP/2.0
[Jul 27 15:39:00] Via: SIP/2.0/UDP 192.168.0.100:5060;rport;branch=z9hG4bKPj9835cd52-f58e-4bb3-8638-ce49c476b745
[Jul 27 15:39:00] From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=8aab90b0-5920-446b-8b0e-a2e078fc988d
[Jul 27 15:39:00] To: <sip:686xxxxxx@telefonica.net>;tag=16335917-1690465137350
[Jul 27 15:39:00] Call-ID: 4b86e96f-2fd0-464c-8df8-56e89774f577
[Jul 27 15:39:00] CSeq: 15587 ACK
[Jul 27 15:39:00] Route: <sip:10.31.255.134:5070;lr>
[Jul 27 15:39:00] Max-Forwards: 70
[Jul 27 15:39:00] User-Agent: Asterisk PBX 20.2.1
[Jul 27 15:39:00] Content-Length:  0
[Jul 27 15:39:00] 
[Jul 27 15:39:00] 
[Jul 27 15:39:02] e[1;31mWARNINGe[0m[512]: e[1;37mres_http_websocket.ce[0m:e[1;37m559e[0m e[1;37mws_safe_reade[0m: Web socket closed abruptly
[Jul 27 15:39:02] e[1;30m  == e[0mWebSocket connection from '192.168.0.1:39749' closed
[Jul 27 15:39:03] <--- Transmitting SIP request (582 bytes) to UDP:10.31.255.134:5070 --->
[Jul 27 15:39:03] REGISTER sip:10.31.255.134:5070 SIP/2.0
[Jul 27 15:39:03] Via: SIP/2.0/UDP 192.168.0.100:5060;rport;branch=z9hG4bKPj2d911267-3e2c-4a22-905d-cf324aa196a1
[Jul 27 15:39:03] From: <sip:949xxxxxx@telefonica.net>;tag=e1c21537-e04a-4a00-abc2-b83703daa72c
[Jul 27 15:39:03] To: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:39:03] Call-ID: d1775aea-a93a-47f7-8c10-2affd3d078be
[Jul 27 15:39:03] CSeq: 45388 REGISTER
[Jul 27 15:39:03] Contact: <sip:949xxxxxx@192.168.0.100:5060>
[Jul 27 15:39:03] Expires: 3600
[Jul 27 15:39:03] Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
[Jul 27 15:39:03] Supported: path
[Jul 27 15:39:03] Max-Forwards: 70
[Jul 27 15:39:03] User-Agent: Asterisk PBX 20.2.1
[Jul 27 15:39:03] Content-Length:  0
[Jul 27 15:39:03] 
[Jul 27 15:39:03] 
[Jul 27 15:39:03] <--- Received SIP response (773 bytes) from UDP:10.31.255.134:5070 --->
[Jul 27 15:39:03] SIP/2.0 200 OK
[Jul 27 15:39:03] Via: SIP/2.0/UDP 192.168.0.100:5060;received=10.29.1.241;branch=z9hG4bKPj2d911267-3e2c-4a22-905d-cf324aa196a1;rport=5060
[Jul 27 15:39:03] From: <sip:949xxxxxx@telefonica.net>;tag=e1c21537-e04a-4a00-abc2-b83703daa72c
[Jul 27 15:39:03] To: <sip:949xxxxxx@telefonica.net>;tag=aprqv2ii1gecd3pa6-t9ev0o0008cp4
[Jul 27 15:39:03] Call-ID: d1775aea-a93a-47f7-8c10-2affd3d078be
[Jul 27 15:39:03] CSeq: 45388 REGISTER
[Jul 27 15:39:03] P-Associated-URI: <sip:949xxxxxx@telefonica.net>
[Jul 27 15:39:03] P-Associated-URI: <tel:+34949xxxxxx>
[Jul 27 15:39:03] P-Associated-URI: <sip:f2018009635772_1@telefonica.net>
[Jul 27 15:39:03] Contact: <sip:949xxxxxx@10.29.3.206:5060;transport=udp>;expires=340
[Jul 27 15:39:03] Contact: <sip:949xxxxxx@192.168.0.100:5060>;expires=70
[Jul 27 15:39:03] Contact: <sip:949xxxxxx@192.168.0.8:5060>;expires=2995
[Jul 27 15:39:03] Service-Route: <sip:949xxxxxx@10.31.255.134:5070;transport=udp;lr>
[Jul 27 15:39:03] Content-Length: 0
[Jul 27 15:39:03] 
[Jul 27 15:39:03] 
[Jul 27 15:39:03] e[1;31mWARNINGe[0m[513]: e[1;37mres_http_websocket.ce[0m:e[1;37m559e[0m e[1;37mws_safe_reade[0m: Web socket closed abruptly
[Jul 27 15:39:04] e[1;30m  == e[0mWebSocket connection from '192.168.0.1:39811' for protocol 'sip' accepted using version '13'
[Jul 27 15:39:04] e[1;30m  == e[0mWebSocket connection from '192.168.0.1:39751' closed
[Jul 27 15:39:04] e[1;30m    -- e[0mRegistered SIP '100' at 192.168.0.1:39811
[Jul 27 15:39:05] e[1;30m  == e[0mWebSocket connection from '192.168.0.1:39813' for protocol 'sip' accepted using version '13'
[Jul 27 15:39:05] e[1;30m    -- e[0mRegistered SIP '100' at 192.168.0.1:39813

EDIT: This is actually the first time I can see the INVITE PJSIP dialog. I didn’t check how to get PJSIP logging until you asked me to do so. I can see those “Anonymous” From: fields coming out from Asterisk. Why?? Am I missing any parameter in my pjsip.conf?

Okay, it’s doing exactly what it has been configured to do. When using the “originate” CLI command no callerid is provided by “originate” and thus it is Anonymous. If you want it to always be your number you can set the “from_user” on the endpoint in pjsip.conf to your number which may allow it to happen, otherwise you would need to use a Local channel which executes dialplan that sets a callerid before dialing the PJSIP endpoint.

For example:

[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)
originate Local/686xxxxxx@external-calls application Playback tt-monkeys

You are THE MAN! Thank you so much!

For the moment, I can tell that the combination of this command…

originate Local/686454828@external-calls application Playback tt-monkeys

… and this dialplan…

[external-calls]
exten => _[67]XXXXXXXX,1,NoOP(Llamadas a moviles)
same => n,Set(CALLERID(all)=949382875 <949382875>)
same => n,NoOp(CALLERID(all))
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)

… works all right.

For me, it is enough for the purpose, because I need to dial a single number only. However, I’d love to understand the background so will do some further tests according to your feedback. I see a lot of potential in this Asterisk thing and I am keen to learn more!

For example, I tried to set either from_user=949382875 and from_user=949382875 <949382875>, in my endpoint but neither worked. Actually, if I insert such lines like both options below, Asterisk replies in the log upon placing a call that the endpoint does not exist:

[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_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 <949xxxxxx>
from_domain=telefonica.net
callerid=asreceived
send_pai=yes
rewrite_contact=no
send_pai=yes
send_rpid=yes

Is there any syntax mistake here?

Configuration is validated at configuration load time. If something is not correct, it is stated on the Asterisk console or in the Asterisk log.

1 Like

you may want to play arount with asterisklint to ensure that your syntax is correct

I will definitely take a look at that. Thanks!

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