Sunr1ses / google-voice-sipsorcery-dialplans

Automatically exported from code.google.com/p/google-voice-sipsorcery-dialplans
1 stars 0 forks source link

Dial Out - "Error loading dial plan" #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Dial out from X-Lite or Fring for iPhone

What is the expected output? What do you see instead?
Expect that call will successfully dial out using Gizmo5 or Sipgate, based on 
Complex Dial Plan 
in SIPsorcery.

What version of the product are you using? On what operating system?
Mac OSX 10.6.2
X-Lite Beta 3 (it says 3, but I think it's 4), Build 56227

Please provide any additional information below.
I've tried both Simple and Complex dial plans.  Both return the same error in 
SIPSorcery: dial plan 
could not be loaded.

CUSTOMIZED DIAL PLAN:

#Ruby

# Copyright 2010 Mike Telis and Steven Jackson
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# Script is based on a script originally posted by Mike Telis

# Note: This script works with both gizmo5 and sipgate but some EDITS ARE
#    REQUIRED to indicate which SIP provider is being used

# Click "View raw file" in the lower right for the best copy/paste view

# --------BEGIN MANDATORY ENTRIES SECTION-----------------------------#         

Area = '503'          # my area code, this will be added to 7-digit dialouts
Tz   = +8             # my time zone (GMT format, e.g. Eastern = -5, Central = 
-6)

# ---- Enter your Google Voice ("GV") and Sipgate account credentials----#

GV_USER = "gsiebengartner@gmail.com"       # my GV e-mail address 
(user@gmail.com)
GV_PASS = "XXXXXXXXX"                  # my GV password
SG_NUMBER = "5038788422"             # my 10-digit Sipgate number (not always 
415)
G5_NUMBER = "7472236711"             # my 10-digit Gizmo5 number (always 747)

# ***************Google Voice Configuration Section *********************

def googleVoice_SG

  sys.GoogleVoiceCall(GV_USER,GV_PASS,SG_NUMBER,@num,'.*',1,30) # sipgate

end

def googleVoice_G5

  sys.GoogleVoiceCall(GV_USER,GV_PASS,G5_NUMBER,@num,'.*',7,30) # Gizmo5

end

# ***************SIP Provider Configuration Section *********************

VSPtab = {
  '0' => '00 @ Sipgate',                # SIPGate default route
  '2' => '02 @ Sipgate',                # SIPGate grey route
  '3' => '03 @ Sipgate',                # SIPGate white route
  '4' => '04 @ Sipgate',                # SIPGate premium route
  '5' => '@ Sipgate',              # sipgate
  '6' => '@ Gizmo',                # gizmo

}

# ------END MANDATORY ENTRIES SECTION-----------------------------#             

# --------BEGIN OPTIONAL SECTION FOR SPEED DIAL--------------------#            

# Speed dial entries. Format: "short code" => "destination (POTS or SIP)"

Speeddial = {
  '0'   => '123456789',                # my 0 (zero) key's speeddial number
  '1'   => 'wwwxxxyyyy',             # home speed dial
  '411' => '8004664411',               # Google's Directory Assistance, GOOG-411  
  '303' => '303@sip.blueface.ie',      # Blueface speaking clock (Ireland time)
  '266' => '4153767253@podlinez.net',  # CNN Headlines (266 = "CNN")
  '677' => '8186882773@podlinez.net',  # NPR's most e-mailed stories (677 ="NPR")                     
  '742' => '6506441934@podlinez.net',  # Prairie Home Companion's, or PHC's
                                       # News from Lake Wobegon (742 = "PHC")
   '932' => '7755333366',              # Columbus OH-based national weather (932 = "WEA[ther]")                    

}
# --------END OPTIONAL SPEED DIAL ENTRY SECTION---------------#                 

# Serviced domains, must be in lowercase!

Domains  = ['sipsorcery.com','174.129.236.7']

# Excluded Prefixes. Provides a safeguard against accidentally calling premium
# numbers. Accepts both strings and patterns, spaces ignored

ExcludedPrefixes = [
   ' 1 (900 | 976 | 809)',            # USA Premium
   '44 (9 | 55 | 87 (0|1))',          # UK Premium
   '44 84 (4|5)',                     # UK Local Premium
   '44 70',                           # UK Personal Premium
   '43 (8|9)',                        # Austria Premium
   '32 (7|90)',                       # Belgium Premium
   '45 (1 | 50 (1|2|3) | 70 (1|2))',  # Denmark Premium
   '45 (8|9) 0',                      # Denmark Premium (...)
   '33 (7|9)',                        # France Premium
   '49 (1 | 900)',                    # Germany Premium
   '39 [^3]',                         # Italy Premium (...)
   '31 (14 | 6 (3|8|9) | 8 | 9)',     # Netherlands Premium (...)
   '48 (39 | (2|7|8) 0)',             # Poland Premium
   '46 9 (00 | 39 | 44)',             # Sweden Premium
   '41 90 (0|1|6)',                   # Switzerland Premium
]

# ********************  s e l e c t   V S P  ***************

def selectVSP    # VoIP provider selection

# Reject calls to premium numbers unless VSP was forced

  ExcludedPrefixes.each {|p| p.gsub!(/\s*/,''); sys.Respond(503,"Calls to #{$1}* not allowed") if 
@num =~ Regexp.new("^(#{p})")}

  case @num
    when /^1([2-9]\d\d)/                 # North America

      case $1                            # check area code

         when /^4(1?747\d{7})$/ then    # Gizmo5 to Gizmo5 calls when Gizmo5 enabled
         if G5_NUMBER != "747xxxyyyy"
            route(6,"Gizmo5 to Gizmo5 call")
         end

       else

         if SG_NUMBER != "415xxxyyyy" # Place GV call via SIPGate (preferred) or Gizmo5
            googleVoice_SG
         else
            googleVoice_G5
         end

         sys.Log("GoogleVoiceCall failed, routing thru SIPGate")
         route(4,"Destination - North America non-GV")
       end

    when /^972(5|6)/                    # Israel mobile
       route(3,"Destination - Israel mobile")
    else
      route(0,"Default route applied")
  end
end

# **************************  C A L L    S W I T C H  **********************

def callswitch(num,*args)
  route                 # Initialize vars

  @num = num unless @num = Speeddial[num]     # If there is speed dial entry for it...

  @l = "URI dialing: #{@num}" # Assume URI dialing
  unless @num =~ /@/          # If we already have URI, skip all number processing
    @num.gsub!(/%(..)/) {$1.to_i(16).chr} # Convert %hh into ASCII

#==========================================
# Note: this section is important to understand because it lets users choose a 
specific
#    SIP Provider for each outbound call. Perfect for users both sipgate and G5
#    accounts who want to be able to choose which provider to use. Let's develop
#    this section to make the script portable to both G5 and sipgate users as 
well
#    as user with other 3rd party SIP providers

    if @num =~ /^#(.)(.*)/    # If number starts with '#'
      @p = $1; @num = $2      # next char is VSP code
    end
#==============================================

    @num.gsub!(/[^0-9*+]/,'') # Delete all fancy chars (only digits, '+' and '*' allowed)

    # sub! below removes prefixes:
    #  '+' - international format
    #   00 - European style international prefix (00)
    #  011 - US style international prefix (011)

    unless @num.sub!(/^(\+|00|011)/,'')  # If no international prefix, process special cases below
      case @num
        when /^[2-9]\d{6,6}$/       # Local call, 7-digit number
          @num = "1#{Area}#{@num}"  # prefix it with country and area code
        when /^[01]?([2-9]\d{9,9})/ # US number with or without "1" country code
          @num = '1' + $1           # add country code and truncate number to 10-digit
        when /^\*/                  # Voxalot voicemail, echotest & other special numbers
          else
            sys.Respond(603,'Wrong number, check & dial again')
      end
    end

    sys.Log("Number in ENUM format: #{@num}")

    @l = "Forced routing to provider #{@p}, template '#{VSPtab[@p]}'" # Assume user explicitly 
selected VSP

    if @p.empty?        # Automatic VSP selection?

      # Invoke selectVSP prior to ENUM lookup just in case we need to modify @num

      route                 # re-initialize variables
      selectVSP             # Pick appropriate provider for the call

      if enumuri = sys.ENUMLookup("+#{@num}.e164.org") # Check if NAPTR exists for the number
        sys.Log("ENUM entry found: '#{enumuri}'")      # If yes, call that URI
        sys.Dial(enumuri)                              # if call failed, call via regular VSP.
        status()                                       # If this is not what you want, add "return"
        sys.Log("Call to #{enumuri} failed (#{@reason}), will call again via regular VoIP provider")
      end

    end # @p.empty
  end   # URI

  dial(*args)   # dial selected number or URI
end

# *******************************  D I A L  ********************************

def dial(*args)
  sys.Log(@l) unless @l.empty?               # for the record :)
  if tpl=VSPtab[@p.to_s]                     # if provider is in our table
    tpl.gsub!(/\s*/,'')                      # Remove spaces
    @num = tpl.gsub(/@/,@num+'@')            # Insert number before '@'
  end
  sys.Dial(@num,*args) # Dial
  status()             # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")
end

# ******************************  R O U T E  *******************************

def route(p='', l='')
  @p = p; @l = l
end

# *****************************  S T A T U S  ******************************

def status
  if (ptr = sys.LastDialled[0]).nil?
    @code = 487; @reason = 'Cancelled by Sipsorcery'
  else
    ptr = ptr.TransactionFinalResponse
    @code = ptr.StatusCode; @reason = ptr.ReasonPhrase
#   sys.Log("#{ptr.ToString()}")
  end
end

# *******************************  M A I N  *****************************
begin
  sys.Log("** Call from #{req.Header.From.ToString()} to #{req.URI.User} **")

  t = Time.now + ((Tz+8)*60*60)  # Get current time and adjust to local. SS Server is in GMT-8
  sys.Log(t.strftime('Local time: %c'))

if sys.In               # If incoming call...
    name = req.Header.from.FromURI.User.to_s     # get a copy of caller's number

    # Prefix 10-digit numbers with "1" (US country code).
    # Some DID send Caller ID without country code

    name = ('1' + name) if name =~ /^[2-9]\d\d[2-9]\d{6}$/

    name.sub!(/^011/,'') # Remove 011 prefix added by Google Voice

    sys.Log("FromName: '#{name}'")
    req.Header.From.FromName = name    # Set FromName for sys.Dial
    # Change FromURI.User, too - or else Bria won't find contact in its phonebook!
    req.Header.from.FromURI.User = name

    if sys.IsAvailable()                  # If my ATA is registered
      callswitch("#{sys.Username}@local") # forward all incoming calls to it
    elsif (8..23) === t.hour              # else forward calls to my home
      sys.Log("#{sys.Username} is not online, forwarding call to home number...")
      callswitch("0",35)                  # Note that '0' is in my speed dial list
    end

    sys.Respond(480, "#{sys.Username} Not online") # switch to voice mail

  else                    # Outbound call ...

    # check if it's URI or phone number.
    # If destination's host is in our domain, it's a phone call

    num = req.URI.User.to_s; reqHost = req.URI.Host.to_s  # Get User and Host
    host = reqHost.downcase.slice(/[^:]+/)                # Convert to lowercase and delete optional 
":port"

    num << '@' << reqHost unless Domains.find {|x| x == host} # URI dialing unless host is in our 
domain list

    callswitch(num)

  end
  sys.Respond(@code,@reason) # Forward error code to ATA
rescue
   # Gives a lot more details at what went wrong (borrowed from Myatus' dialplan)
   sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end

RECENT OUTPUT FROM SIP SORCERY CONSOLE:

Monitor 03:11:07:958: ipaddress=*, user=gsiebengartner, event=*, request=*, 
serveripaddress=*, server=*, regex=.*.
Monitor 03:11:08:628: ipaddress=*, user=gsiebengartner, event=*, request=*, 
serveripaddress=*, server=*, regex=.*.
ContactRegisterInProgress 03:11:23:129: Checking SIP Provider registration for 
Sipgate.
ContactRegisterInProgress 03:11:23:129: Sending initial register for 
gsiebengartner and Sipgate 
to udp:204.155.28.10:5060.
ContactRegisterInProgress 03:11:23:254: Initiating registration for 
gsiebengartner on 
sip:sipgate.com.
DialPlan 03:11:23:709: New call from tcp:114.36.120.156:48347 successfully 
authenticated by 
digest.
DialPlan 03:11:23:974: Dialplan could not be loaded for Out call to 
sip:15039146440@sipsorcery.com.
DialPlan 03:11:23:974: UAS call failed with a response status of 500 and Error 
loading dial plan.
ContactRegistered 03:11:23:629: Contact successfully registered for 
gsiebengartner on 
sip:sipgate.com, expiry 600s.
Registrar 03:11:26:410: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:11:27:475: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:11:28:520: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:11:30:022: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:11:31:082: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
BindingInProgress 03:11:32:160: New binding request for 
gsiebengartner@sipsorcery.com from 
udp:63.219.16.149:52615, expiry requested 3600s granted 3600s.
RegisterSuccess 03:11:32:270: Registration successful for 
gsiebengartner@sipsorcery.com from 
udp:63.219.16.149:52615 (proxy=udp:10.215.50.4:5060), expiry 3600s.
Registrar 03:14:33:609: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:14:35:469: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:14:35:734: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
BindingInProgress 03:14:36:578: New binding request for 
gsiebengartner@sipsorcery.com from 
udp:63.219.16.145:52748, expiry requested 3600s granted 3600s.
RegisterSuccess 03:14:36:687: Registration successful for 
gsiebengartner@sipsorcery.com from 
udp:63.219.16.145:52748 (proxy=udp:10.248.58.129:5060), expiry 3600s.
Registrar 03:14:34:418: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:14:34:668: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:16:12:173: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:16:13:396: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
Registrar 03:16:14:454: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
DialPlan 03:16:44:663: New call from tcp:114.36.120.156:48347 successfully 
authenticated by 
digest.
DialPlan 03:16:44:913: Dialplan could not be loaded for Out call to 
sip:15039146440@sipsorcery.com.
DialPlan 03:16:44:913: UAS call failed with a response status of 500 and Error 
loading dial plan.
Registrar 03:18:55:044: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
BindingExpired 03:18:55:482: Binding expired by client for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:48347.
RegisterSuccess 03:18:55:529: Registration successful for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:48347 (proxy=tcp:10.248.58.129:5060), expiry -1s.
Registrar 03:19:03:607: Authentication required for 
gsiebengartner@sipsorcery.com from 
udp:127.0.0.1:5060.
BindingInProgress 03:19:04:014: New binding request for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:34943, expiry requested 3600s granted 3600s.
RegisterSuccess 03:19:04:123: Registration successful for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:34943 (proxy=tcp:10.248.58.129:5060), expiry 3600s.
BindingExpired 03:19:04:529: Binding expired by client for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:34943.
RegisterSuccess 03:19:04:561: Registration successful for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:34943 (proxy=tcp:10.248.58.129:5060), expiry -1s.
BindingInProgress 03:19:04:967: New binding request for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:34943, expiry requested 3600s granted 3600s.
RegisterSuccess 03:19:05:076: Registration successful for 
gsiebengartner@sipsorcery.com from 
tcp:114.36.120.156:34943 (proxy=tcp:10.248.58.129:5060), expiry 3600s.
DialPlan 03:19:14:311: New call from tcp:114.36.120.156:34943 successfully 
authenticated by 
digest.
DialPlan 03:19:14:561: Dialplan could not be loaded for Out call to 
sip:5039146440@sipgate.com.
DialPlan 03:19:14:561: UAS call failed with a response status of 500 and Error 
loading dial plan.
DialPlan 03:20:08:501: New call from tcp:114.36.120.156:34943 successfully 
authenticated by 
digest.
DialPlan 03:20:08:814: Dialplan could not be loaded for Out call to 
sip:+15039146440@sipsorcery.com.
DialPlan 03:20:08:814: UAS call failed with a response status of 500 and Error 
loading dial plan.
DialPlan 03:20:17:533: New call from tcp:114.36.120.156:34943 successfully 
authenticated by 
digest.
DialPlan 03:20:17:783: Dialplan could not be loaded for Out call to 
sip:+16095587861@sipsorcery.com.
DialPlan 03:20:17:783: UAS call failed with a response status of 500 and Error 
loading dial plan.
ContactRegisterInProgress 03:21:20:640: Checking SIP Provider registration for 
Sipgate.
ContactRegisterInProgress 03:21:20:640: Sending initial register for 
gsiebengartner and Sipgate 
to udp:204.155.28.10:5060.
ContactRegisterInProgress 03:21:20:765: Initiating registration for 
gsiebengartner on 
sip:sipgate.com.
ContactRegistered 03:21:21:155: Contact successfully registered for 
gsiebengartner on 
sip:sipgate.com, expiry 600s.

Original issue reported on code.google.com by gsiebengartner on 23 Jan 2010 at 3:34

GoogleCodeExporter commented 9 years ago
Thank you for the nice detailed posting, but that error has been resolved 
numerous
times by deleting and recreating the SIP Sorcery account. There's something in 
their
provisioning system that misfires on accounts every so often. 

Original comment by easter...@gmail.com on 24 Jan 2010 at 1:48

GoogleCodeExporter commented 9 years ago

Original comment by easter...@gmail.com on 24 Jan 2010 at 1:49

GoogleCodeExporter commented 9 years ago
Thanks.  Sorry about that - I tried searching for solutions before posting.  
Will proceed as you suggest.

Original comment by gsiebengartner on 24 Jan 2010 at 1:59

GoogleCodeExporter commented 9 years ago
No problem! I appreciate your using the ticketing system. Will keep this open 
to see
if it resolves it for you as well.

Original comment by easter...@gmail.com on 24 Jan 2010 at 2:05

GoogleCodeExporter commented 9 years ago
I assume this was fixed as the suggested fix was given nearly 4 months ago.

Original comment by easter...@gmail.com on 28 Apr 2010 at 5:51