I am trying to send SMS via asterisk.
I added the following lines to sip.conf:
accept_outofcall_message = yes
outofcall_message_context = messages
auth_message_requests = yes
And my message context in dialplan is:
[messages]
exten => _XX,1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})
exten => _XXXXXXXX,1,MessageSend(sip:${EXTEN}@myisp.com,""<sip:username@myisp.com>)
I successfully may send IM between extensions.
But if I try to send SMS to the outside number, my sip provider asks for authentication which asterisk ignores.
<--- SIP read from UDP:192.168.1.5:59688 --->
MESSAGE sip:88888888@192.168.1.4 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.5:59688;rport;branch=z9hG4bKPj3bad6edd8c074235949866c2a2dabb2a
Max-Forwards: 70
From: <sip:01@192.168.1.4>;tag=a57fe3bb3bb443c883d6ed07e7ad8c3f
To: <sip:88888888@192.168.1.4>
Call-ID: 561a6ecf40cc48c48a87753263bac453
CSeq: 2933 MESSAGE
Accept: text/plain, application/im-iscomposing+xml
User-Agent: MicroSIP/3.19.17
Route: <sip:192.168.1.4;lr>
Authorization: Digest username="01", realm="asterisk", nonce="7b7aebc2", uri="sip:88888888@192.168.1.4", response="ba56f722bb453a214b8d12cf94e328de", algorithm=MD5
Content-Type: text/plain
Content-Length: 4
asdf
<------------->
--- (13 headers 1 lines) ---
Receiving message!
Found peer '01' for '01' from 192.168.1.5:59688
Looking for 88888888 in messages (domain 192.168.1.4)
<--- Transmitting (no NAT) to 192.168.1.5:59688 --->
SIP/2.0 202 Accepted
Via: SIP/2.0/UDP 192.168.1.5:59688;branch=z9hG4bKPj3bad6edd8c074235949866c2a2dabb2a;received=192.168.1.5;rport=59688
From: <sip:01@192.168.1.4>;tag=a57fe3bb3bb443c883d6ed07e7ad8c3f
To: <sip:88888888@192.168.1.4>;tag=as4e7b3b54
Call-ID: 561a6ecf40cc48c48a87753263bac453
CSeq: 2933 MESSAGE
Server: Asterisk PBX 15.7.3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0
<------------>
Scheduling destruction of SIP dialog '561a6ecf40cc48c48a87753263bac453' in 6400 ms (Method: MESSAGE)
-- Executing [88888888@messages:1] MessageSend("Message/ast_msg_queue", "sip:88888888@myisp.com,""<sip:+77777777@myisp.com>") in new stack
Reliably Transmitting (no NAT) to myisp.com:5060:
MESSAGE sip:88888888@myisp.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5060;branch=z9hG4bK73606fe4
Max-Forwards: 70
From: "asterisk" <sip:+77777777@myisp.com>;tag=as5e948041
To: <sip:88888888@myisp.com>
Contact: <sip:+77777777@192.168.1.4:5060>
Call-ID: 1c1632815fdd06374f43c1955264e960@127.0.1.1:5060
CSeq: 102 MESSAGE
User-Agent: Asterisk PBX 15.7.3
Content-Type: text/plain;charset=UTF-8
Content-Length: 4
asdf
---
Scheduling destruction of SIP dialog '1c1632815fdd06374f43c1955264e960@127.0.1.1:5060' in 32000 ms (Method: MESSAGE)
-- Auto fallthrough, channel 'Message/ast_msg_queue' status is 'UNKNOWN'
<--- SIP read from UDP:myisp.com:5060 --->
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.1.4:5060;branch=z9hG4bK73606fe4
Call-ID: 1c1632815fdd06374f43c1955264e960@127.0.1.1:5060
From: "asterisk"<sip:+77777777@myisp.com>;tag=as5e948041
To: <sip:88888888@myisp.com>;tag=6kvx7v64
CSeq: 102 MESSAGE
Warning: 399 38002.588.S.261.12.102.0.17.34315.0.0.myisp.com "Proxy authentication required"
Reason: Q.850;cause=21,SIP;cause=407
Proxy-Authenticate: Digest realm="myisp.com",nonce="jRAwB6IWO+Up+WByL/ZGCA==",algorithm=MD5,qop="auth"
Content-Length: 0
<------------->
--- (10 headers 0 lines) ---
Really destroying SIP dialog '1c1632815fdd06374f43c1955264e960@127.0.1.1:5060' Method: MESSAGE
<--- SIP read from UDP:myisp.com:5060 --->
hello
<------------->
Really destroying SIP dialog '30e8958105222637443249k28105rmwp' Method: REGISTER
Really destroying SIP dialog '561a6ecf40cc48c48a87753263bac453' Method: MESSAGE
<--- SIP read from UDP:192.168.1.5:59688 --->
<------------->
I am able to successfully send SMS directly from softphone. Unlike asterisk, it responses to provider with following packet.
from myisp.com
User Datagram Protocol, Src Port: 5060, Dst Port: 54881
Session Initiation Protocol (407)
Status-Line: SIP/2.0 407 Proxy Authentication Required
Message Header
Via: SIP/2.0/UDP 192.168.1.5:54881;branch=z9hG4bKPjd9b1dc4d7ae94fffa665dd88b306c04b;rport
Call-ID: 84163001760a43409bc389a709c3a3cc
[Generated Call-ID: 84163001760a43409bc389a709c3a3cc]
From: <sip:+77777777@myisp.com>;tag=fbf7cd40c65d49af8a0479d246d04fd8
To: <sip:88888888@myisp.com>;tag=4e6l4e4z
CSeq: 23005 MESSAGE
Warning: 399 38002.588.S.261.12.103.0.17.34315.0.0.myisp.com "Proxy authentication required"
Reason: Q.850;cause=21,SIP;cause=407
Proxy-Authenticate: Digest realm="myisp.com",nonce="pTC6Oa+VIWowZl+4+voIMw==",algorithm=MD5,qop="auth"
Content-Length: 0
---------------------------------------------------------------------------------------------------------------------
to myisp.com
User Datagram Protocol, Src Port: 54881, Dst Port: 5060
Session Initiation Protocol (MESSAGE)
Request-Line: MESSAGE sip:88888888@myisp.com SIP/2.0
Message Header
Via: SIP/2.0/UDP 192.168.1.5:54881;rport;branch=z9hG4bKPjd9d00cdb5f9c411faa40b0c5d5cf3145
Max-Forwards: 70
From: <sip:+77777777@myisp.com>;tag=fbf7cd40c65d49af8a0479d246d04fd8
To: <sip:88888888@myisp.com>
Call-ID: 84163001760a43409bc389a709c3a3cc
[Generated Call-ID: 84163001760a43409bc389a709c3a3cc]
CSeq: 23006 MESSAGE
Accept: text/plain, application/im-iscomposing+xml
User-Agent: MicroSIP/3.19.17
Route: <sip:myisp.com;lr>
[truncated]Proxy-Authorization: Digest username="+77777777@myisp.com", realm="myisp.com", nonce="pTC6Oa+VIWowZl+4+voIMw==", uri="sip:88888888@myisp.com", response="0c5235a285cef4c9e132af09bb4113d1", algorithm=MD5,
Content-Type: text/plain
Content-Length: 11
How to send SMS via asterisk