Matthew Jordan
2015-Sep-21 15:01 UTC
[asterisk-users] Respond to an out of call SIP MESSAGE
On Mon, Sep 21, 2015 at 9:45 AM, D'Arcy J.M. Cain <darcy at vex.net> wrote:> On Mon, 21 Sep 2015 06:48:52 +0000 > Emil Ohlsson <emo at svep.se> wrote: >> [sip-im] >> exten _X!, 1, NoOp(Got message) >> exten _X!, n, Answer() >> exten _X!, n, Agi(agi://localhost/messagehandler.agi?...) >> exten _X!, n, SendText(Message received) > > I am not an expert but perhaps you want this. > > [sip-im] > exten s,1,NoOp(Got message) > same,n,Answer() > same,n,Agi(agi://localhost/messagehandler.agi?...) > same,n,SendText(Message received) > > Replacing "exten _X!" with "same" is just a shortcut. I find that > there are lots of places where spaces cause problems so I just remove > them all for good measure. Finally, I am not sure what the mechanism > is here but if it is like a goto then I think that you want the 's' > priority. > > Or, I totally don't know what I am talking about and my education will > be advanced by the replies to this message. :-) >If you want to send an out of call SIP MESSAGE request, you'll need to use the MessageSend application: https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Application_MessageSend SendText is used for sending text messages within a call. Since a SIP channel is not servicing the out of call text message, you cannot use it to send a SIP MESSAGE request back to whatever sent the original SIP MESSAGE request. -- Matthew Jordan Digium, Inc. | Director of Technology 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us out at: http://digium.com & http://asterisk.org
Yes, that is how the problem was solved before when the transport protocol for messages was UDP, but TLS (TCP) this doesn't work. Partly because MessageSend doesn't support SIPS and partly because it focuses on sending a new message instead of reusing an existing stream. Using wireshark I can see that the TLS stream is still alive as there is no tear down communication. The "same,n," is a good shortcut to make the text more readable, I'll add that but I don't think that is the cause as I can follow the source code and see that the SendText command is executed but fails silently. Thanks for the feedback, Emil ________________________________________ From: Matthew Jordan <mjordan at digium.com> Sent: Monday, September 21, 2015 5:01 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Cc: Emil Ohlsson Subject: Re: [asterisk-users] Respond to an out of call SIP MESSAGE On Mon, Sep 21, 2015 at 9:45 AM, D'Arcy J.M. Cain <darcy at vex.net> wrote:> On Mon, 21 Sep 2015 06:48:52 +0000 > Emil Ohlsson <emo at svep.se> wrote: >> [sip-im] >> exten _X!, 1, NoOp(Got message) >> exten _X!, n, Answer() >> exten _X!, n, Agi(agi://localhost/messagehandler.agi?...) >> exten _X!, n, SendText(Message received) > > I am not an expert but perhaps you want this. > > [sip-im] > exten s,1,NoOp(Got message) > same,n,Answer() > same,n,Agi(agi://localhost/messagehandler.agi?...) > same,n,SendText(Message received) > > Replacing "exten _X!" with "same" is just a shortcut. I find that > there are lots of places where spaces cause problems so I just remove > them all for good measure. Finally, I am not sure what the mechanism > is here but if it is like a goto then I think that you want the 's' > priority. > > Or, I totally don't know what I am talking about and my education will > be advanced by the replies to this message. :-) >If you want to send an out of call SIP MESSAGE request, you'll need to use the MessageSend application: https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Application_MessageSend SendText is used for sending text messages within a call. Since a SIP channel is not servicing the out of call text message, you cannot use it to send a SIP MESSAGE request back to whatever sent the original SIP MESSAGE request. -- Matthew Jordan Digium, Inc. | Director of Technology 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us out at: http://digium.com & http://asterisk.org
On 15-09-22 03:53 AM, Emil Ohlsson wrote:> Yes, that is how the problem was solved before when the transport > protocol for messages was UDP, but TLS (TCP) this doesn't work. > Partly because MessageSend doesn't support SIPS and partly because it > focuses on sending a new message instead of reusing an existing > stream. Using wireshark I can see that the TLS stream is still alive > as there is no tear down communication.What is the complete console output as well as endpoint configuration? It should work fine, provided stuff is configured and used right. -- Joshua Colp Digium, Inc. | Senior Software Developer 445 Jan Davis Drive NW - Huntsville, AL 35806 - US Check us out at: www.digium.com & www.asterisk.org
Sorry for the delay here. For some reason the mail from Joshua Colp failed to deliver to my mailbox. So, anyway, I've set up a local scenario on my computer a PJSIP client and Asterisk 11.17.1 (On a fedora linux workstation) with the settings listed below. In this scenario I've used UDP, but I want a configuration that can be used with any transport protocol. I can see that the context runs correctly, but there is no message delivered to the client. Am I approaching this the wrong way? sip.conf: [general] context=public ; Default context for incoming calls. Defaults to 'default' allowoverlap=no ; Disable overlap dialing support. (Default is yes) realm=my_realm ; Realm for digest authentication udpbindaddr=0.0.0.0 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all) tcpenable=no ; Enable server for incoming TCP connections (default is no) tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces) transport=udp ; Set the default transports. The order determines the primary default transport. srvlookup=yes ; Enable DNS SRV lookups on outbound calls accept_outofcall_message = yes ; Disable this option to reject all MESSAGE requests outside of a outofcall_message_context = tutorial ; Context all out of dialog msgs are sent to. When this [authentication] [alice] type=friend host=dynamic username=alice secret=TopSecret nat=no transport=udp context=tutorial extensions.conf: [general] static=yes writeprotect=no clearglobalvars=no [tutorial] exten => _X!,1,NoOp(Got message) exten => _X!,n,Answer() exten => _X!,n,SendText(Zup dawg) exten => _X!,n,NoOp(Done with message) And when I run the scenario I get the following log: <--- SIP read from UDP:127.0.0.1:5059 ---> REGISTER sip:127.0.0.1:5060 SIP/2.0 Via: SIP/2.0/UDP 127.0.0.1:5059;rport;branch=z9hG4bKPjd629f029-a971-4c83-9920-bb02da26cc25 Max-Forwards: 70 From: <sip:alice at 127.0.0.1>;tag=4b251b50-2a30-498c-a7bd-9502271e8ac2 To: <sip:alice at 127.0.0.1> Call-ID: be616b5b-a301-477e-a4bc-c011bcecd4f0 CSeq: 17321 REGISTER Contact: <sip:alice at 127.0.0.1:5059;ob> Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Content-Length: 0 <-------------> --- (11 headers 0 lines) --- Sending to 127.0.0.1:5059 (no NAT) Sending to 127.0.0.1:5059 (no NAT) <--- Transmitting (no NAT) to 127.0.0.1:5059 ---> SIP/2.0 401 Unauthorized Via: SIP/2.0/UDP 127.0.0.1:5059;branch=z9hG4bKPjd629f029-a971-4c83-9920-bb02da26cc25;received=127.0.0.1;rport=5059 From: <sip:alice at 127.0.0.1>;tag=4b251b50-2a30-498c-a7bd-9502271e8ac2 To: <sip:alice at 127.0.0.1>;tag=as62d4da5c Call-ID: be616b5b-a301-477e-a4bc-c011bcecd4f0 CSeq: 17321 REGISTER Server: Asterisk PBX 11.17.1 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE Supported: replaces, timer WWW-Authenticate: Digest algorithm=MD5, realm="my_realm", nonce="394fd8d9" Content-Length: 0 <------------> Scheduling destruction of SIP dialog 'be616b5b-a301-477e-a4bc-c011bcecd4f0' in 32000 ms (Method: REGISTER) <--- SIP read from UDP:127.0.0.1:5059 ---> REGISTER sip:127.0.0.1:5060 SIP/2.0 Via: SIP/2.0/UDP 127.0.0.1:5059;rport;branch=z9hG4bKPj8905923d-2405-45dc-97c9-8abb213075c7 Max-Forwards: 70 From: <sip:alice at 127.0.0.1>;tag=4b251b50-2a30-498c-a7bd-9502271e8ac2 To: <sip:alice at 127.0.0.1> Call-ID: be616b5b-a301-477e-a4bc-c011bcecd4f0 CSeq: 17322 REGISTER Contact: <sip:alice at 127.0.0.1:5059;ob> Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Authorization: Digest username="alice", realm="my_realm", nonce="394fd8d9", uri="sip:127.0.0.1:5060", response="e72c84753c7768e0048c094d37ac6c70", algorithm=MD5 Content-Length: 0 <-------------> --- (12 headers 0 lines) --- Sending to 127.0.0.1:5059 (no NAT) <--- Transmitting (no NAT) to 127.0.0.1:5059 ---> SIP/2.0 200 OK Via: SIP/2.0/UDP 127.0.0.1:5059;branch=z9hG4bKPj8905923d-2405-45dc-97c9-8abb213075c7;received=127.0.0.1;rport=5059 From: <sip:alice at 127.0.0.1>;tag=4b251b50-2a30-498c-a7bd-9502271e8ac2 To: <sip:alice at 127.0.0.1>;tag=as62d4da5c Call-ID: be616b5b-a301-477e-a4bc-c011bcecd4f0 CSeq: 17322 REGISTER Server: Asterisk PBX 11.17.1 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE Supported: replaces, timer Expires: 300 Contact: <sip:alice at 127.0.0.1:5059;ob>;expires=300 Date: Mon, 28 Sep 2015 12:03:22 GMT Content-Length: 0 <------------> Scheduling destruction of SIP dialog 'be616b5b-a301-477e-a4bc-c011bcecd4f0' in 32000 ms (Method: REGISTER) <--- SIP read from UDP:127.0.0.1:5059 ---> MESSAGE sip:1234 at 127.0.0.1:5060 SIP/2.0 Via: SIP/2.0/UDP 127.0.0.1:5059;rport;branch=z9hG4bKPjb2135f5d-b7ba-43e6-a1d9-1f2729b2f1b2 Max-Forwards: 70 From: <sip:alice at 127.0.0.1>;tag=c12f77aa-d0d5-4517-8430-bf4406006397 To: <sip:1234 at 127.0.0.1> Call-ID: 1b6ac040-4af5-4015-a85d-fb5c48831d6f CSeq: 1266 MESSAGE Accept: text/plain, application/im-iscomposing+xml Content-Type: text/plain Content-Length: 13 Hello, world! <-------------> --- (10 headers 1 lines) --- Sending to 127.0.0.1:5059 (no NAT) Receiving message! Found peer 'alice' for 'alice' from 127.0.0.1:5059 <--- Transmitting (no NAT) to 127.0.0.1:5059 ---> SIP/2.0 401 Unauthorized Via: SIP/2.0/UDP 127.0.0.1:5059;branch=z9hG4bKPjb2135f5d-b7ba-43e6-a1d9-1f2729b2f1b2;received=127.0.0.1;rport=5059 From: <sip:alice at 127.0.0.1>;tag=c12f77aa-d0d5-4517-8430-bf4406006397 To: <sip:1234 at 127.0.0.1>;tag=as32a0932b Call-ID: 1b6ac040-4af5-4015-a85d-fb5c48831d6f CSeq: 1266 MESSAGE Server: Asterisk PBX 11.17.1 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE Supported: replaces, timer WWW-Authenticate: Digest algorithm=MD5, realm="my_realm", nonce="0698f476" Content-Length: 0 <------------> Scheduling destruction of SIP dialog '1b6ac040-4af5-4015-a85d-fb5c48831d6f' in 32000 ms (Method: MESSAGE) Scheduling destruction of SIP dialog '1b6ac040-4af5-4015-a85d-fb5c48831d6f' in 32000 ms (Method: MESSAGE) <--- SIP read from UDP:127.0.0.1:5059 ---> MESSAGE sip:1234 at 127.0.0.1:5060 SIP/2.0 Via: SIP/2.0/UDP 127.0.0.1:5059;rport;branch=z9hG4bKPj71f66ce8-9f0f-4841-aca8-ced79085ad65 Max-Forwards: 70 From: <sip:alice at 127.0.0.1>;tag=c12f77aa-d0d5-4517-8430-bf4406006397 To: <sip:1234 at 127.0.0.1> Call-ID: 1b6ac040-4af5-4015-a85d-fb5c48831d6f CSeq: 1267 MESSAGE Accept: text/plain, application/im-iscomposing+xml Authorization: Digest username="alice", realm="my_realm", nonce="0698f476", uri="sip:1234 at 127.0.0.1:5060", response="8d4ebff55b35d0363e4cd726c8f410c7", algorithm=MD5 Content-Type: text/plain Content-Length: 13 Hello, world! <-------------> --- (11 headers 1 lines) --- Receiving message! Found peer 'alice' for 'alice' from 127.0.0.1:5059 Looking for 1234 in tutorial (domain 127.0.0.1) <--- Transmitting (no NAT) to 127.0.0.1:5059 ---> SIP/2.0 202 Accepted Via: SIP/2.0/UDP 127.0.0.1:5059;branch=z9hG4bKPj71f66ce8-9f0f-4841-aca8-ced79085ad65;received=127.0.0.1;rport=5059 From: <sip:alice at 127.0.0.1>;tag=c12f77aa-d0d5-4517-8430-bf4406006397 To: <sip:1234 at 127.0.0.1>;tag=as32a0932b Call-ID: 1b6ac040-4af5-4015-a85d-fb5c48831d6f CSeq: 1267 MESSAGE Server: Asterisk PBX 11.17.1 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE Supported: replaces, timer Content-Length: 0 <------------> Scheduling destruction of SIP dialog '1b6ac040-4af5-4015-a85d-fb5c48831d6f' in 32000 ms (Method: MESSAGE) -- Executing [1234 at tutorial:1] NoOp("Message/ast_msg_queue", "Got message") in new stack -- Executing [1234 at tutorial:2] Answer("Message/ast_msg_queue", "") in new stack -- Executing [1234 at tutorial:3] SendText("Message/ast_msg_queue", "Zup dawg") in new stack -- Executing [1234 at tutorial:4] NoOp("Message/ast_msg_queue", "Done with message") in new stack -- Auto fallthrough, channel 'Message/ast_msg_queue' status is 'UNKNOWN' BR, Emil ________________________________________ From: Emil Ohlsson Sent: Tuesday, September 22, 2015 8:53 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] Respond to an out of call SIP MESSAGE Yes, that is how the problem was solved before when the transport protocol for messages was UDP, but TLS (TCP) this doesn't work. Partly because MessageSend doesn't support SIPS and partly because it focuses on sending a new message instead of reusing an existing stream. Using wireshark I can see that the TLS stream is still alive as there is no tear down communication. The "same,n," is a good shortcut to make the text more readable, I'll add that but I don't think that is the cause as I can follow the source code and see that the SendText command is executed but fails silently. Thanks for the feedback, Emil ________________________________________ From: Matthew Jordan <mjordan at digium.com> Sent: Monday, September 21, 2015 5:01 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Cc: Emil Ohlsson Subject: Re: [asterisk-users] Respond to an out of call SIP MESSAGE On Mon, Sep 21, 2015 at 9:45 AM, D'Arcy J.M. Cain <darcy at vex.net> wrote:> On Mon, 21 Sep 2015 06:48:52 +0000 > Emil Ohlsson <emo at svep.se> wrote: >> [sip-im] >> exten _X!, 1, NoOp(Got message) >> exten _X!, n, Answer() >> exten _X!, n, Agi(agi://localhost/messagehandler.agi?...) >> exten _X!, n, SendText(Message received) > > I am not an expert but perhaps you want this. > > [sip-im] > exten s,1,NoOp(Got message) > same,n,Answer() > same,n,Agi(agi://localhost/messagehandler.agi?...) > same,n,SendText(Message received) > > Replacing "exten _X!" with "same" is just a shortcut. I find that > there are lots of places where spaces cause problems so I just remove > them all for good measure. Finally, I am not sure what the mechanism > is here but if it is like a goto then I think that you want the 's' > priority. > > Or, I totally don't know what I am talking about and my education will > be advanced by the replies to this message. :-) >If you want to send an out of call SIP MESSAGE request, you'll need to use the MessageSend application: https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Application_MessageSend SendText is used for sending text messages within a call. Since a SIP channel is not servicing the out of call text message, you cannot use it to send a SIP MESSAGE request back to whatever sent the original SIP MESSAGE request. -- Matthew Jordan Digium, Inc. | Director of Technology 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us out at: http://digium.com & http://asterisk.org