Cant receive text message with SIP

Hi everyone,

I’m trying to implement text messaging into my asterisk server. I can send a message to server but seems like receiver can’t receive it. I didn’t understand what is wrong. I can see that my message accepted from the terminal and SIP client;

I add the lines below into [general] section on my sip.conf file:

accept_outofcall_message=yes.
outofcall_message_context=MENSAGEIRO
auth_message_requests=yes

And I add this section into my extensions.conf file:

[MENSAGEIRO]
exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
;exten => _.,n,AGI(chatplan.php,${MESSAGE(from)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,ExecIf($["${ACTUALTO}" != "sip:${EXTEN}"]?Set(ACTUALTO=sip:${EXTEN}))
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
exten => _.,n,Hangup()
;; Handle failed messaging
exten => _.,n(sendfailedmsg),NoOp(Sending error to user)
exten => _.,n,Set(SRC=${MESSAGE(from)})
exten => _.,n,Set(DST=${MESSAGE(to)})
exten => _.,n,Set(MSG=${MESSAGE(body)})
exten => _.,n,Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} failed. Receiver is offline.")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
;exten => _.,n,GotoIf($["${INQUEUE}" != "1"]?startq)
exten => _.,n,Hangup()

I opened the debugger and this is what it’s print: (Note: I changed the IP of my server with SERVERIP, and user IP with USERIP)

SIP Debugging enabled

<--- SIP read from UDP:PCIP:59853 --->
MESSAGE sip:7001@SERVERIP SIP/2.0
Via: SIP/2.0/UDP PCIP:59853;rport;branch=z9hG4bKPj3f66ab11399b48049184dcdcdd04104c
Max-Forwards: 70
From: <sip:7003@SERVERIP>;tag=d994bd1f776545a783f6410741cc5c93
To: <sip:7001@SERVERIP>
Call-ID: 3f2128122f8f4eccbdf9140059599072
CSeq: 803 MESSAGE
User-Agent: MicroSIP/3.20.7
Content-Type: text/plain
Content-Length: 12

Hello there!
<------------->
--- (10 headers 1 lines) ---
Sending to PCIP:59853 (no NAT)
Receiving message!
Found peer '7003' for '7003' from PCIP:59853

<--- Transmitting (no NAT) to PCIP:59853 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP PCIP:59853;branch=z9hG4bKPj3f66ab11399b48049184dcdcdd04104c;received=PCIP;rport=59853
From: <sip:7003@SERVERIP>;tag=d994bd1f776545a783f6410741cc5c93
To: <sip:7001@SERVERIP>;tag=as2a8ccb64
Call-ID: 3f2128122f8f4eccbdf9140059599072
CSeq: 803 MESSAGE
Server: Asterisk PBX 18.11.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="0b233612"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '3f2128122f8f4eccbdf9140059599072' in 32000 ms (Method: MESSAGE)
Scheduling destruction of SIP dialog '3f2128122f8f4eccbdf9140059599072' in 32000 ms (Method: MESSAGE)

<--- SIP read from UDP:PCIP:59853 --->
MESSAGE sip:7001@SERVERIP SIP/2.0
Via: SIP/2.0/UDP PCIP:59853;rport;branch=z9hG4bKPj374895f2d57e49e59e1e5d73dd8b0559
Max-Forwards: 70
From: <sip:7003@SERVERIP>;tag=d994bd1f776545a783f6410741cc5c93
To: <sip:7001@SERVERIP>
Call-ID: 3f2128122f8f4eccbdf9140059599072
CSeq: 804 MESSAGE
User-Agent: MicroSIP/3.20.7
Authorization: Digest username="7003", realm="asterisk", nonce="0b233612", uri="sip:7001@SERVERIP", response="79428214085d2c2dbdb8d5a219a17f70", algorithm=MD5
Content-Type: text/plain
Content-Length: 12

Hello there!
<------------->
--- (11 headers 1 lines) ---
Receiving message!
Found peer '7003' for '7003' from PCIP:59853
Looking for 7001 in MENSAGEIRO (domain SERVERIP)

<--- Transmitting (no NAT) to PCIP:59853 --->
SIP/2.0 202 Accepted
Via: SIP/2.0/UDP PCIP:59853;branch=z9hG4bKPj374895f2d57e49e59e1e5d73dd8b0559;received=PCIP;rport=59853
From: <sip:7003@SERVERIP>;tag=d994bd1f776545a783f6410741cc5c93
To: <sip:7001@SERVERIP>;tag=as2a8ccb64
Call-ID: 3f2128122f8f4eccbdf9140059599072
CSeq: 804 MESSAGE
Server: Asterisk PBX 18.11.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '3f2128122f8f4eccbdf9140059599072' in 32000 ms (Method: MESSAGE)
    -- Executing [7001@MENSAGEIRO:1] NoOp("Message/ast_msg_queue", "SMS receiving dialplan invoked") in new stack
    -- Executing [7001@MENSAGEIRO:2] NoOp("Message/ast_msg_queue", "To sip:7001@SERVERIP") in new stack
    -- Executing [7001@MENSAGEIRO:3] NoOp("Message/ast_msg_queue", "From <sip:7003@SERVERIP>") in new stack
    -- Executing [7001@MENSAGEIRO:4] NoOp("Message/ast_msg_queue", "Body Hello there!") in new stack
    -- Executing [7001@MENSAGEIRO:5] Set("Message/ast_msg_queue", "ACTUALTO=sip:7001") in new stack
    -- Executing [7001@MENSAGEIRO:6] ExecIf("Message/ast_msg_queue", "0?Set(ACTUALTO=sip:7001)") in new stack
    -- Executing [7001@MENSAGEIRO:7] MessageSend("Message/ast_msg_queue", "sip:7001,<sip:7003@SERVERIP>") in new stack
Reliably Transmitting (no NAT) to PCIP:39748:
MESSAGE sip:7001@PCIP:39748;transport=udp SIP/2.0
Via: SIP/2.0/UDP SERVERIP:5060;branch=z9hG4bK54e7ee8b
Max-Forwards: 70
From: "asterisk" <sip:7003@SERVERIP>;tag=as5c55f985
To: <sip:7001@PCIP:39748;transport=udp>
Contact: <sip:7003@SERVERIP:5060>
Call-ID: 5fcbe6c03e3792617c1abf913b443dc3@172.31.92.63:5060
CSeq: 102 MESSAGE
User-Agent: Asterisk PBX 18.11.1
Content-Type: text/plain;charset=UTF-8
Content-Length: 12

Hello there!
---
Scheduling destruction of SIP dialog '5fcbe6c03e3792617c1abf913b443dc3@172.31.92.63:5060' in 11968 ms (Method: MESSAGE)
    -- Executing [7001@MENSAGEIRO:8] NoOp("Message/ast_msg_queue", "Send status is SUCCESS") in new stack
    -- Executing [7001@MENSAGEIRO:9] GotoIf("Message/ast_msg_queue", "0?sendfailedmsg") in new stack
    -- Executing [7001@MENSAGEIRO:10] Hangup("Message/ast_msg_queue", "") in new stack
  == Spawn extension (MENSAGEIRO, 7001, 10) exited non-zero on 'Message/ast_msg_queue'
Retransmitting #1 (no NAT) to PCIP:39748:
MESSAGE sip:7001@PCIP:39748;transport=udp SIP/2.0
Via: SIP/2.0/UDP SERVERIP:5060;branch=z9hG4bK54e7ee8b
Max-Forwards: 70
From: "asterisk" <sip:7003@SERVERIP>;tag=as5c55f985
To: <sip:7001@PCIP:39748;transport=udp>
Contact: <sip:7003@SERVERIP:5060>
Call-ID: 5fcbe6c03e3792617c1abf913b443dc3@172.31.92.63:5060
CSeq: 102 MESSAGE
User-Agent: Asterisk PBX 18.11.1
Content-Type: text/plain;charset=UTF-8
Content-Length: 12

Hello there!
---

<--- SIP read from UDP:PCIP:39748 --->
SIP/2.0 200 Ok
Via: SIP/2.0/UDP SERVERIP:5060;branch=z9hG4bK54e7ee8b
From: "asterisk" <sip:7003@SERVERIP>;tag=as5c55f985
To: <sip:7001@PCIP:39748;transport=udp>;tag=ZoL9JyP
Call-ID: 5fcbe6c03e3792617c1abf913b443dc3@172.31.92.63:5060
CSeq: 102 MESSAGE

<------------->
--- (6 headers 0 lines) ---
Really destroying SIP dialog '5fcbe6c03e3792617c1abf913b443dc3@172.31.92.63:5060' Method: MESSAGE

<--- SIP read from UDP:PCIP:39748 --->
SIP/2.0 200 Ok
Via: SIP/2.0/UDP SERVERIP:5060;branch=z9hG4bK54e7ee8b
From: "asterisk" <sip:7003@SERVERIP>;tag=as5c55f985
To: <sip:7001@PCIP:39748;transport=udp>;tag=ZoL9JyP
Call-ID: 5fcbe6c03e3792617c1abf913b443dc3@172.31.92.63:5060
CSeq: 102 MESSAGE

<------------->
--- (6 headers 0 lines) ---
ip-172-31-92-63*CLI> sip set debug off
SIP Debugging Disabled

Any help or thought would be great! Thanks in an advance…

UPDATE

I think problem seems to be caused by Linphone. Because I can send message from MicroSIP client to Linphone and it can receive it (Actually, Linphone mobile app can receive it. Linphone Windows version doesn’t.).

But I can’t send message from Linphone to MicroSIP or Linphone to Linphone. Right now it throws the [${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} failed. Receiver is offline.") message.I will update this comment if I can find a solution about it.

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