MessageSend error "not a valid SIP/SIPS URI"

(trying to resurrect an old messaging config, that used to work without issues?)

Fighting with following error on MessageSend dialplan app in endpoints with message_context enabled

WARNING[1436]: res_pjsip.c:3338 ast_sip_update_to_uri: To address '7006@asterisk20.misc' is not a valid SIP/SIPS URI

But messages are delivered without issues!!! (just with error in console and log)

And error only appears when using MessageSend trough message_context in endpoint.
If using MessageSend trough normal context there is no errors!!! (log bellow)

On asterisk 16.28.0~dfsg-0+deb11u4 from deb package.
And on asterisk 20.15.1 compiled without modifications.

Using basic-pbx configs to start, and adding/removing modules/configs to a bare minimum/needed.
to start and run without warning/errors, and satisfy required functionality.

Went trough too many permutations of proper URI format for MessageSend and am stuck!!!

(minimal configs for testing the messaging errors)

pjsip.conf:

[global]

user_agent=Astersik-pavilion1-agent

[transport-udp]
type=transport
protocol=udp
bind=192.168.30.101:5060
local_net=192.168.30.0/24
allow_reload=yes

[general]

; =============================== phones ==============================

; +++++++++++++++++++++++ template wifi softphones +++++++++++++++++++++++

[endpoint_wifi](!)
type=endpoint
transport=transport-udp
disallow=all
allow=ulaw
allow=h263					; video
allow=h264					; video
direct_media=no
device_state_busy_at=1

[auth_wifi](!)
type=auth
auth_type=userpass

[aor_wifi](!)
type=aor
max_contacts=1
remove_existing=yes			; removes stale registrations
minimum_expiration=1800
default_expiration=3600
maximum_expiration=7200


; ---------------------------------------------------------
[7004](endpoint_wifi)
auth=7004
aors=7004
context=internal
message_context=astsms
callerid=samsung-s4 <7004>

[7004](auth_wifi)
password=1234
username=7004

[7004](aor_wifi)

; ---------------------------------------------------------
[7006](endpoint_wifi)
auth=7006
aors=7006
context=internal
message_context=astsms
callerid=razr-m <7006>


[7006](auth_wifi)
password=1234
username=7006

[7006](aor_wifi)

extensions.conf:

[globals]



[general]

static=yes
writeprotect=yes
autofallthrough=yes
clearglobalvars=no
;userscontext=default


[internal]


exten => _700X,1,NoOp([internal] dialplan invoked)
	same => n,Verbose(3, NOTICE, Call from ${CALLERID(all)} to ${EXTEN} )s
	same => n,Dial(PJSIP/${EXTEN},30)
	same => n,Hangup()

exten => 9999,1,NoOp([internal] message test invoked)
		same => n,Set(MESSAGE(body)='test test test')
		same => n,MessageSend(pjsip:7006,7004)
		same => n,Hangup()

[astsms]

exten => _700X,1,NoOp([astsms] SMS dialplan invoked)
	same => n,Verbose(3, NOTICE, Message from ${MESSAGE(From)} to ${MESSAGE(To)})
	
	same => n,NoOp(To ${MESSAGE(to)})
	same => n,NoOp(From ${MESSAGE(from)})
	same => n,NoOp(Body ${MESSAGE(body)})

	same => n,Set(ACTUALTO=${CUT(CUT(MESSAGE(to),@,1),:,2)})
	same => n,Set(ACTUALFROM=${CUT(CUT(MESSAGE(from),@,1),:,2)})

	;same => n,MessageSend(pjsip:7006,7004)
	same => n,MessageSend(pjsip:${ACTUALTO},${ACTUALFROM})
	;same => n,MessageSend(pjsip:sip:${ACTUALTO},${ACTUALFROM})
	;same => n,MessageSend(pjsip:sip:${ACTUALTO}@asterisk20.misc,${ACTUALFROM})
	;same => n,MessageSend(pjsip:sip:7006@asterisk20.misc,${ACTUALFROM})

	same => n,Hangup()

console log:

    -- Executing [7006@astsms:1] NoOp("Message/ast_msg_queue", "[astsms] SMS dialplan invoked") in new stack
    -- Executing [7006@astsms:2] Verbose("Message/ast_msg_queue", "3, NOTICE, Message from <sip:7004@asterisk20.misc> to pjsip:7006@asterisk20.misc") in new stack
    --  NOTICE, Message from <sip:7004@asterisk20.misc> to pjsip:7006@asterisk20.misc
    -- Executing [7006@astsms:3] NoOp("Message/ast_msg_queue", "To pjsip:7006@asterisk20.misc") in new stack
    -- Executing [7006@astsms:4] NoOp("Message/ast_msg_queue", "From <sip:7004@asterisk20.misc>") in new stack
    -- Executing [7006@astsms:5] NoOp("Message/ast_msg_queue", "Body Test") in new stack
    -- Executing [7006@astsms:6] Set("Message/ast_msg_queue", "ACTUALTO=7006") in new stack
    -- Executing [7006@astsms:7] Set("Message/ast_msg_queue", "ACTUALFROM=7004") in new stack
    -- Executing [7006@astsms:8] MessageSend("Message/ast_msg_queue", "pjsip:7006,7004") in new stack
[Aug  9 12:48:09] WARNING[1476]: res_pjsip.c:3338 ast_sip_update_to_uri: To address '7006@asterisk20.misc' is not a valid SIP/SIPS URI
    -- Executing [7006@astsms:9] Hangup("Message/ast_msg_queue", "") in new stack
  == Spawn extension (astsms, 7006, 9) exited non-zero on 'Message/ast_msg_queue'
  
    -- Executing [9999@internal:1] NoOp("PJSIP/7004-00000001", "[internal] message test invoked") in new stack
    -- Executing [9999@internal:2] Set("PJSIP/7004-00000001", "MESSAGE(body)='test test test'") in new stack
    -- Executing [9999@internal:3] MessageSend("PJSIP/7004-00000001", "pjsip:7006,7004") in new stack
    -- Executing [9999@internal:4] Hangup("PJSIP/7004-00000001", "") in new stack
  == Spawn extension (internal, 9999, 4) exited non-zero on 'PJSIP/7004-00000001'

Thanx

The error in this case is indicating that the URI does not start with a sip: or sips: scheme, ie;

sip:7006@asterisk20.misc

Tried this (commented out lines in extensions.conf)

[Aug 11 20:32:37]     -- Executing [7006@astsms:8] MessageSend("Message/ast_msg_queue", "pjsip:sip:7006@asterisk20.misc,7004") in new stack
[Aug 11 20:32:37] ERROR[1561]: res_pjsip_messaging.c:1259 msg_send: PJSIP MESSAGE - Could not find endpoint 'sip:7006@asterisk20.misc' and no default outbound endpoint configured

What is the proper way of using MessageSend to an endpoint and not a URI?

As far as MessageSend documentation, i infer that you should be able to
just send to an endpoints name, and it will get all the info from an AOR .

The following dialplan:
exten => 714,1,noOp()
same => n,Answer()
same => n,Set(MESSAGE(body)=Hello Banjo!)
same => n,MessageSend(pjsip:Banjo,Carrot,Banjo)
same => n,Hangup()

Results in the following message:

MESSAGE sip:Banjo@10.0.0.45:5260;ob SIP/2.0
Via: SIP/2.0/UDP 10.0.0.45:62857;rport;branch=z9hG4bKPj25b899eb-2fc5-4a3d-85ee-facb3207f67c
From: sip:Carrot@10.0.0.45;tag=6152a470-6988-4b71-853d-9b90cfc7f4cb
To: sip:Banjo@10.0.0.45;ob
Contact: sip:Banjo@10.0.0.45:62857
Call-ID: 1107b236-7bec-4569-8fc6-8ea6f993a169
CSeq: 6406 MESSAGE
Supported: path
Max-Forwards: 70
User-Agent: Asterisk PBX GIT-master-b0421fc87c
Content-Type: text/plain
Content-Length: 12

Hello Banjo!

What does your 7006 aor look like (specifically the contact)?
core show aor 7006

pjsip show aor 7006

      Aor:  <Aor..............................................>  <MaxContact>
    Contact:  <Aor/ContactUri............................> <Hash....> <Status> <RTT(ms)..>
==========================================================================================

      Aor:  7006                                                 1
    Contact:  7006/sip:7006@192.168.30.236:34021;ob        d57005f1eb NonQual         nan


 ParameterName        : ParameterValue
 =======================================================
 authenticate_qualify : false
 contact              : sip:7006@192.168.30.236:34021;ob
 default_expiration   : 3600
 mailboxes            : 
 max_contacts         : 1
 maximum_expiration   : 7200
 minimum_expiration   : 1800
 outbound_proxy       : 
 qualify_frequency    : 0
 qualify_timeout      : 3.000000
 remove_existing      : true
 remove_unavailable   : false
 support_path         : false
 voicemail_extension  :

outgoing to 7006

2025/08/12 01:46:51.920166 192.168.30.101:5060 -> 192.168.30.236:34021
MESSAGE sip:7006@192.168.30.236:34021;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.30.101:5060;rport;branch=z9hG4bKPj3f2742dc-1106-4a5b-a35e-5f86dc038aad
From: <sip:7004@192.168.30.101>;tag=22f45a99-e606-4ec3-9a3b-0b13f63c82e1
To: <sip:7006@192.168.30.236;ob>
Contact: <sip:7006@192.168.30.101:5060>
Call-ID: c794d43c-5851-4a68-a5f4-45cbfbf0e456
CSeq: 32820 MESSAGE
Max-Forwards: 70
User-Agent: Astersik-pavilion1-agent
Content-Type: text/plain
Content-Length:     4

Test
2025/08/12 01:46:52.296391 192.168.30.236:34021 -> 192.168.30.101:5060
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.30.101:5060;rport=5060;received=192.168.30.101;branch=z9hG4bKPj3f2742dc-1106-4a5b-a35e-5f86dc038aad
Call-ID: c794d43c-5851-4a68-a5f4-45cbfbf0e456
From: <sip:7004@192.168.30.101>;tag=22f45a99-e606-4ec3-9a3b-0b13f63c82e1
To: <sip:7006@192.168.30.236;ob>;tag=z9hG4bKPj3f2742dc-1106-4a5b-a35e-5f86dc038aad
CSeq: 32820 MESSAGE
Content-Length:  0

(Messages get delivered without problems, just the constant WARNING in console/log about URI)

Now tried asterisk v16,18,20 with same exact result

And WARNINGS only when going trough message_context not regular context

I think the warning is a bug based on these results combined with some of my back-to-back testing, please go ahead and submit an issue here.

There also may be an issue with the Contact header, I will submit a ticket if confirmed.

I have created an issue for the Contact header:

Opened an issue

Thanx