Respond To An Out Of Call SIP MESSAGE

Home » Asterisk Users » Respond To An Out Of Call SIP MESSAGE
Asterisk Users 12 Comments

Hi,

I’m having trouble configuring Asterisk to respond to an incoming out of call SIP MESSAGE. The transport protocol is TLS and the Asterisk version is 10 (it’s old, but I’m kind of stuck with it at the moment). Currently I have roughly the following configuration and handling:

sip.conf:

[general]
accet_outofcall_messages=yes outofcall_message_context=sip-im

and extensions.conf

[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 can see in the log from Asterisk that the script in the sip-im context is running, but there is no message sent. I have followed the code in the call, and it seems like there is no channel registered with the SendText application. Is there some other approach that I could use to send a SIP MESSAGE back to the client? Does the client need to register for this to work?

BR, Emil

12 thoughts on - Respond To An Out Of Call SIP MESSAGE

  • Could it be in the [general] section you should have;

    accept_outofcall_message=yes

    Your line appears to be missing the ‘p’ in accept and an extraneous ‘s’
    in message.

    Larry.

  • 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. 🙂

  • 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

  • What is the complete console output as well as endpoint configuration?
    It should work fine, provided stuff is configured and used right.

  • 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 (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.

  • As Matt stated the SendText application is for sending messages in-dialog within a call. It can’t be used out of call. You have to use the MessageSend application.

  • (Still no not receiving the mail, revisited the settings.)

    OK, so SendText doesn’t work with this scenario. But can MessageSend handle this, and respond even when the transport protocol is TLS? Or do I need to modify Asterisk to add this support?

    BR, Emil

  • MessageSend has no concept of TLS, it gets passed to chan_sip which then sends it. It’s therefore up to chan_sip to do it. It should work. Haven’t done it though.

  • Ah, so I can use

    MessageSend(sip:alice)

    to send a message to Alice then (reusing the existing TLS session). That does seem to work. Thanks :-). I didn’t know you could use users there.

    Is there a variable or some other method to see which user that did send the message? I’m thinking something in the lines of

    [context]
    exten => _X!,1,NoOp(Handling message from ${SENDER})

    I didn’t see any useful information using dumpchan, so I’m guessing there isn’t any variable for it. $CALLERID(name) didn’t contain the name and $SIP_HEADER seems to be focused on calls.

    Since the information is in the SIP header it should be possible to get.

    /E