Text Message between SS phones

Getting started with the SIP Sorcery
calvinng
Posts: 20
Joined: Thu Mar 01, 2012 1:08 am

Re: Text Message between SS phones

Post by calvinng » Fri Sep 14, 2012 8:57 pm

Hello Aaron,

Thanks so much for your help. I really appreciate it. I have modified your code a little bit here:

if req.Method.to_s == "MESSAGE"
#
# Check if the text body contains garbage
#
if req.Body.to_s =~ /^\<\?x/
sys.Log("** User is active in writing a message")
sys.SendRequest("MESSAGE","myaccount@sipsorcery.com", "text/html", "", 0)
else
#
# Check to see if the recipient has a SIP URI address or a telephone number.
#
num = req.URI.User.to_s
sys.Log("**Recipient of the message: #{num}")
case num
when /^(\+1)?1?([2-9]\d{9})$/
#
# Use Google SMS to send message to recipient if the recipient contains telephone number
#
sys.GoogleVoiceSMS(GV_USER,GV_PASS,"1" + $2, req.Body.to_s)
else
#
# Display Incoming SIMPLE message on the screen
#
sys.Log("** Incoming SIMPLE Message: #{req.Body}")
sys.SendRequest("MESSAGE","myaccount@sipsorcery.com", "text/html", req.Body, 0)
end
end
else
## Do normal Invite processing

The code works but I keep getting a 480 Temporarily Unavailable before and after sending the text message. The full trace is here:

NATKeepAlive 02:09:53:874 sip1(14152): Requesting NAT keep-alive from proxy socket udp:67.222.131.147:5060 to udp:46.19.139.222:58809.
DialPlan 02:09:55:265 sip1(10160): MESSAGE request from udp:46.19.139.222:58809 successfully authenticated by digest.
DialPlan 02:09:55:296 sip1(10160): Using dialplan default for Out call to sip:myaccount@sipsorcery.com.
NewCall 02:09:55:312 sip1(10160): Executing script dial plan for call to myaccount.
DialPlan 02:09:55:358 sip1(10160): ** Call from "Calvin" <sip:myaccount@sipsorcery.com>;tag=46mwlbbfqZEGJjDAhMi1B8t-gcaDQ3Gb to myaccount **
DialPlan 02:09:55:358 sip1(10160): Local Time: 09/15/2012 01:09
DialPlan 02:09:55:358 sip1(10160): ** User is active in writing a message
DialPlan 02:09:55:374 sip1(10160): Call leg is for local domain looking up bindings for myaccount@sipsorcery.com for call leg myaccount@sipsorcery.com.
DialPlan 02:09:55:374 sip1(10160): 1 found for myaccount@sipsorcery.com.
DialPlan 02:09:55:374 sip1(10160): Dialplan cleanup for calvin.
DialPlan 02:09:55:655 sip1(10160): Server response 200 OK received for MESSAGE to sip:myaccount@46.19.139.222:58809;ob.
DialPlan 02:09:55:655 sip1(10160): SendRequest 200 OK response received for MESSAGE to myaccount@sipsorcery.com.
DialPlan 02:09:55:765 sip1(10160): Dial plan execution completed without answering and with no last failure status.
DialPlan 02:09:55:765 sip1(10160): MESSAGE request failed with a response status of 480 .
NATKeepAlive 02:10:03:984 sip1(14152): Requesting NAT keep-alive from proxy socket udp:67.222.131.147:5060 to udp:46.19.139.222:58809.
DialPlan 02:10:12:390 sip1(10160): MESSAGE request from udp:46.19.139.222:58809 successfully authenticated by digest.
DialPlan 02:10:12:406 sip1(10160): Using dialplan default for Out call to sip:myaccount@sipsorcery.com.
NewCall 02:10:12:406 sip1(10160): Executing script dial plan for call to myaccount.
DialPlan 02:10:12:452 sip1(10160): ** Call from "Calvin <sip:myaccount@sipsorcery.com>;tag=RqXSwjaK8Gos6d24xYZ48XFlsa1g.-0X to myaccount **
DialPlan 02:10:12:452 sip1(10160): Local Time: 09/15/2012 01:10
DialPlan 02:10:12:452 sip1(10160): **Recipient of the message: myaccount
DialPlan 02:10:12:452 sip1(10160): ** Incoming SIMPLE Message: Hello
DialPlan 02:10:12:468 sip1(10160): Call leg is for local domain looking up bindings for myaccount@sipsorcery.com for call leg myaccount@sipsorcery.com.
DialPlan 02:10:12:468 sip1(10160): 1 found for myaccount@sipsorcery.com.
DialPlan 02:10:12:468 sip1(10160): Dialplan cleanup for calvin.
DialPlan 02:10:12:781 sip1(10160): Dial plan execution completed without answering and with no last failure status.
DialPlan 02:10:12:781 sip1(10160): MESSAGE request failed with a response status of 480 .
NATKeepAlive 02:10:14:109 sip1(14152): Requesting NAT keep-alive from proxy socket udp:67.222.131.147:5060 to udp:46.19.139.222:58809.

This error message also pops up on my phone indicating that there was a problem. On my phone the message that pops after receiving SIMPLE message is:

Message Error
Temporarily Unavailable (480)
Reason: Temporarily Unavailable

This is basically the same message that could be found in the Sipsorcery log.
What is the fix for this type of error?
Thanks again for your kind assistance.

Calvin

User avatar
Aaron
Site Admin
Posts: 4552
Joined: Thu Jul 12, 2007 12:13 am

Re: Text Message between SS phones

Post by Aaron » Sat Sep 15, 2012 6:08 am

So it sounds like the sending message bit is working properly and now the problem is that the sending phone gets an error message?

The 480 response is returned by SIPSorcery because the dialplan instance did not result in a call getting answered. The assumption is that all SIPSorcery dialplans have the goal of generating a new call and getting an answer on that call. If that doesn't happen a 480 response is generated so the caller knows the dialplan execution was unsuccessful. In this case the assumption doesn't apply because you are not actually interested in a SIP call at all. I'll need to have a bit of a think about the best way to handle that.

calvinng
Posts: 20
Joined: Thu Mar 01, 2012 1:08 am

Re: Text Message between SS phones

Post by calvinng » Tue Sep 18, 2012 4:32 am

Hello Aaron,

Thanks for deducing the source of the problem. I hope you can find a solution to this issue soon. Thanks again for your kind assistance.

Cheers,
Calvin

User avatar
Aaron
Site Admin
Posts: 4552
Joined: Thu Jul 12, 2007 12:13 am

Re: Text Message between SS phones

Post by Aaron » Sat Oct 13, 2012 10:21 am

I was just looking at putting in a solution for this problem and realised it already exists. For non-INVITE requests, such as a MESSAGE request, it's possible to use the sys.Respond method to send an Ok response. So to overcome the issue where your phone is getting back a 480 response after sending a MESSAGE request to sipsorcery you can use:

Code: Select all

# Do all MESSAGE request processing and then when finished use the line below to let the know the original sender everything worked properly.
sys.Respond(200, nil);

Janus
Posts: 2
Joined: Mon Feb 18, 2013 2:04 pm

voip did sms

Post by Janus » Mon Feb 18, 2013 2:54 pm

there are several VSP who are working on SMS capabilities. I expect that'll kill mobile phone rate gouging, first by wielding via SIP SIMPLE, as Aaron mentioned, but also via XMPP... tied in neatly to smart phone [sip] apps.

I've been toying with one such: receive SMS to my DID via email. I await less cumbersome reply procedures.

wildsip
Posts: 23
Joined: Sun Jun 19, 2011 2:42 am

Re: Text Message between SS phones

Post by wildsip » Thu Jan 02, 2014 3:16 am

Edit: Nevermind, I figured it out. It looks like the example dialplan XML configuration files have not yet been updated to reflect the Accept Non-Invite option.

How do I enable "Accept Non-Invite" Messages in the SS local version using XML configuration files ? Is this in the .config file ?

Aaron wrote:To accept MESSAGE requests in your dialplan you need to check the "Accept Non-Invite" check box that's available when you login to the Silverlight portal. Once you do that you'll need to check the method of incoming requests so you can process MESSAGE and INVITE requests differently.

Code: Select all

if req.Method.to_s == "MESSAGE"
  # Do something with MESSAGE requests.
else
  # Do normal INVITE request processing.
end

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest