Re: Text Message between SS phones
Posted: 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
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