**Error: Can't convert VSP into Fixnum

Catalog of dial plans
qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

**Error: Can't convert VSP into Fixnum

Post by qubo » Mon May 09, 2011 4:09 pm

HI mike I hope you can help with this

I use your dialplan version 2 and config MY problem is with the Google Voice number every time I dial with GV the call is not made and always I got a **Error: Can't convert VSP into Fixnum. dont know what is wrong

here my code

Code: Select all

   # Copyright 2010 Mike Telis
# 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.

require 'mikesgem'

# ************* C O N F I G U R A T I O N    S E C T I O N *************** #

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

# Speed dial entries. Format: "key" => "number"

Speeddial = {
  '0'   => '22210910',                 # Home
  '21'   => '*#2 (646) 657-8199',       # New York Voice Mail, dial my NY GV using Santa Monica GV acnt
  '27'   => 'grrivado@sipsorcery.com',       # a grace via sipsorcery account
  '277'   => '10312255',               # Grace
  '411' => '(800) 466-4411',           # 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]")
}

# CNAM table: number in ENUM format => caller's name

CNAM = {
'(212) 555-1212' => 'Dear mom',
'(215) 333-2211' => 'Bratty kid',
}

# Uncomment next line and insert your White Pages API key, if you have it
# WP_key = '427961d1960ac97d0799e6562bbc3bd9dsewe'     # White Pages API key

# Uncomment line below to enable misdialing safeguards
# EnableSafeguards = 1

# Excluded Prefixes. Provides a safeguard against accidentally calling premium numbers

ExcludedPrefixes = [
   ' 1 (900 | 809)',               # USA Premium
   ' 1 \d\d\d 555 1212',           # USA Directory assistance
   ' 52 (900 | 809)',               # Mexico Premium
]

# Yet another safeguard, list of blessed country codes

Allowed_Country = %w{
1 52 54
}

# My own ENUM database

MyENUM = {
'+1 (408) 334-1234' => 'brother@local', # Brother George
}

# Enum database list

EnumDB = [
  MyENUM,                             # look in MyENUM first
'e164.org',
'e164.info',
'e164.arpa',
'e164.televolution.net',
'enum.org',
]

# Serviced domains, must be in lowercase!

Domains  = ['sipsorcery.com','sip.sipsorcery.com','sip1.sipsorcery.com','sip2.sipsorcery.com','69.59.142.213']
Host     = 'sipsorcery.com'        # Replaces "host" on incoming calls

# Google Voice accounts

Myacnt1  = { :usr => '*******', :pwd => '********' }
Myacnt2  = { :usr => '*****', :pwd => '******' }

NYCaccount = [
  Myacnt1 + { :cb => '(305) 760-XXXX' },
  Myacnt1 + { :cb => 'nil' },
  
]

SMaccount = [
  Myacnt2 + { :cb => '(305) 760-XXXX' },
  Myacnt2 + { :cb => ' nil ' },
]

# SIP accounts
                    

Nextel      = VSP.new '#0', '   ${EXTEN}@Nextel',      'nextel default route'
RealEstate  = VSP.new '#2', '   ${EXTEN}@RealEstate',      'realestate route'
VoipBuster  = VSP.new '#3', '0052 ${EXTEN}@VoipBuster',      'Voipbuster Nacional route'
Home        = VSP.new '#4', '   ${EXTEN}@Home',      'Casa route'
DFine          = VSP.new '#5', '   ${EXTEN}@DFine',      'DFine route'
Mont   = VSP.new '#8', '   ${EXTEN}@Mont', 'Mont route'
VoipBuster2 = VSP.new '#9', '00 ${EXTEN}@VoipBuster',  'Voipbuster Internacional Route'
Voxalot     = VSP.new '#6', '   ${EXTEN}@Voxalot',  'Voxalot Internacional Route'
INUM        = VSP.new  nil, '011${EXTEN}@Gizmo',   'Gizmo'

NewYork    = GV.new  '*#1', nil, 'GV-646', :account => NYCaccount,  :repeat => 3
Smonica    = GV.new  '*#2', nil, 'GV-424', :account => SMaccount,  :repeat => 2
Dallas     = GV.new  '*#3', nil, 'GV-214', :usr => '*****', :pwd => '*****',
                                          :cb => '(305) 760-XXXX', :repeat => 2
                                          



            Provider '**', 'DisableSafeGuards'     # Disable safeguards prefix is **

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

def selectVSP    # VoIP provider selection

  case @num
    when /^\*/                                       # For *500, *600 and other Voxalot services
      route_to Voxalot, "Voxalot Services", nil

    when /^883/                                      # iNUM
      route_to INUM, "iNUM", nil                     # disable ENUM

    when /(^1([2-9]\d\d)[2-9]\d{6})/                 # North America
      @num = $1                                      # Truncate to 11 digits
      case $2                                        # check area code
        when "800", "866", "877", "888"              # toll free numbers...
          route_to NewYork, "USA toll-free", nil     # call from GV/New York, disable ENUM search
        when "424"                                   # Santa Monica CA patch, I have GV number there
          route_to Smonica, "Santa Monica"
        when "312", "773", "872"                     # Chicago, I have GV number there
          route_to Chicago, "Chicago"
        else
          route_to NewYork                           # all other destinations within US & Canada
      end

      route_to Ribbit, nil, nil     # If GV call failed, try one more time with Ribbit

  else
    rejectCall(603,"Number's too short, check & dial again") if @num.length < 1
    route_to Nextel
  end
end

# ------------ O P T I O N A L   C O N F I G U R A T I O N --------------- #

# ********************  i n c o m i n g   C a l l  *************************

def incomingCall
  sys.SetFromHeader(formatNum(@cname || @cid,true), nil, Host)  # Set FromName & FromHost for sys.Dial

  # Forward call to the bindings (ATA / softphone)
  # Change FromURI when forwarding to @local, or else Bria won't find contact in its phonebook!

  callswitch("#{@user}@local[fu=#{@cid}]",45) unless (90..745) === @t.hour*100 + @t.min # reject incoming calls from 1:30a to 7:45a

  @code, @reason = 480, "#{@user} is asleep" unless @code # if nothing else, must be the night hour
  @code = 486 if @trunk =~ /IPCOMM/i ## *** temporary fix for IPCOMMS ***
end

# **************************  t o   E N U M  *******************************

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

  # Check if the number begins with one of international prefixes:
  #  '+' - international format
  #   00 - European style international prefix (00)
  #  011 - US style international prefix (011)

  num =~ /^(\+|00|011)/ and return $' # if yes, remove prefix and return

  case num                    # Special cases
    when /^[2-9]\d{6}$/       # Local call, 7-digit number
      '1' + Area + num        # prefix it with country and area code
    when /^[01]?([2-9]\d{9})/ # US number with or without "1" country code
      '1' + $1                # add country code and truncate number to 10-digit
    when /^\*/                # Voxalot voicemail, echotest & other special numbers
      num                     # ... as is
    when /^\d{8}$/            # Llamadas Locales en Guadalajara
      num                     # ... as is
    else
      rejectCall(603,"Wrong number: '#{num}', check & dial again")
  end
end

# ****** E N D   O F   C O N F I G U R A T I O N    S E C T I O N ******** #

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

def callswitch(num,*args)
  @timeout = args[0]
  num.gsub!(/%(..)/) {$1.hex.chr} # Convert %hh into ASCII
  @num = Speeddial[num] || num    # If there is speed dial entry for it...

  if @num =~ /@/              # If we already have URI, just dial and return
    sys.Log("URI dialing: #@num")
    dial(@num,*args)
  else                        # Not URI
    rexp = VSP.tab.keys.sort {|a,b| b.length <=> a.length}.map {|x| Regexp.escape(x)}.join('|')
    if @num =~ /^(#{rexp})/   # If number starts with VSP selection prefix
      @num = $'; @forcedRoute = VSP.tab[$1]
      @noSafeGuards = (@forcedRoute.fmt =~ /Disable\s*Safe\s*Guards/i)
    end

    @num = to_ENUM(@num)      # Convert to ENUM

    rejectCall(503,"Number's empty") if @num.empty?
    sys.Log("Number in ENUM format: #{@num}")
    if @forcedRoute && !@noSafeGuards
      route_to @forcedRoute, "Forced routing!", false # if forced with prefix, skip ENUM, safeguards & VSP selection
    else
      checkNum if defined?(EnableSafeguards) && !@noSafeGuards
      selectVSP               # Pick appropriate provider for the call
    end
  end   # URI
end

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

def route_to vsp, dest=nil, enum = EnumDB
  enum.to_a.each do |db|   # if enum enabled, look in all enum databases
    if uri = (db.class == Hash)? db[@num] : sys.ENUMLookup("#{@num}.#{db}")
      sys.Log("ENUM entry found: '#{uri}' in #{db.class == Hash ? 'local' : db} database")
      dial(uri); break
    end
  end                   # ENUM not found or failed, call via regular VSP

  return unless vsp     # No VSP - do nothing

  uri = vsp.fmt.gsub(/\s+/,'').gsub(/\$\{EXTEN(:([^:}]+)(:([^}]+))?)?\}/) {@num[$2.to_i,$4? $4.to_i : 100]}
  dest &&= " (#{dest})"; with = vsp.name; with &&= " with #{with}"
  sys.Log("Calling #{formatNum(@num)}#{dest}#{with}")

  if vsp.is_gv?
    vsp.repeat.times do |i|
      @code, @reason = 200, "OK"  # assume OK
      sys.GoogleVoiceCall *vsp.getparams(uri, i + (vsp.rand ? @t.to_i : 0))
      sys.Log("Google Voice Call failed!")
      @code, @reason = 603, 'Service Unavailable'
    end
  else
    vsp.repeat.times do
      dial(uri, @timeout || vsp.tmo || 300) # Dial, global time-out overrides account
    end
  end
end

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

def dial *args
  @code, @reason = nil
  sys.Dial *args    # dial URI
  status()          # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")
end

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

def status
  begin
    @code, @reason = 487, 'Cancelled by Sipsorcery'
    sys.LastDialled.each do |ptr|
      if ptr
        ptr = ptr.TransactionFinalResponse
        @code = ptr.StatusCode; @reason = ptr.ReasonPhrase; break if @code == 200
#       sys.Log("#{ptr.ToString()}")
      end
    end
  rescue
  end
end

# ************************  r e j e c t C a l l  ***************************

def rejectCall code, reason
  @code = code; @reason = reason
  sys.Respond code, reason
end

# ****************************  C H E C K   N U M **************************

def checkNum
  return if @num.match(/^\D/)  # skip if number doesn't begin with a digit

  # Reject calls to not blessed countries and premium numbers
  # (unless VSP was forced using #n dial prefix)

  rejectCall(503,"Calls to code #{formatNum(@num).split(' ')[0]} not allowed") \
    unless @num.match "^(#{Allowed_Country.join('|')})"

  rejectCall(503,"Calls to '#{formatNum($&)}' not allowed") if @num.match \
    '^(' + ExcludedPrefixes.map { |x| "(:?#{x.gsub(/\s*/,'')})" }.join('|') + ')'
end

# **********************  k e y s   t o   E N U M  *************************

def keys_to_ENUM (table)
  Hash[*table.keys.map! {|key| to_ENUM(key.dup)}.zip(table.values).flatten]
end

# **************************  g e t T I M E  *******************************

def getTime
  Time.now + ((Tz-6)*60*60) # Get current time and adjust to local. SS Server is in GMT-6
end

# *******************************  M A I N  ********************************

begin
  sys.Log("** Call from #{req.Header.From} to #{req.URI.User} **")
  sys.ExtendScriptTimeout(15)   # preventing long running dialscript time-out
  @t = getTime()
  sys.Log(@t.strftime('Local time: %c'))
  EnumDB.map! {|x| x.class == Hash ? keys_to_ENUM(x) : x } # rebuild local ENUM table

  if sys.In               # If incoming call...
    @cid = req.Header.from.FromURI.User.to_s    # Get caller ID

    # Prepend 10-digit numbers with "1" (US country code) and remove int'l prefix (if present)

    @cid = ('1' + @cid) if @cid =~ /^[2-9]\d\d[2-9]\d{6}$/
    @cid.sub!(/^(\+|00|011)/,'')   # Remove international prefixes, if any

    prs = req.URI.User.split('.')  # parse User into chunks
    @trunk = prs[-2]               # get trunk name
    @user  = prs[-1]               # called user name

    # Check CNAM first. If not found and US number, try to lookup caller's name in Whitepages

    if !(@cname = keys_to_ENUM(CNAM)[@cid]) && @cid =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)
      url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.whitepages.com%2Freverse_phone%2F1.0%2F%3Fphone%3D#{$1}%3Bapi_key%3D#{WP_key}'%20and%20itemPath%3D'wp.listings.listing'&format=json"
      if js = sys.WebGet(url,4).to_s
        @cname, dname, city, state = %w(businessname displayname city state).map {|x| js =~ /"#{x}":"([^"]+)"/; $1}
        @cname ||= dname; @cname ||= "#{city}, #{state}" if city && state
      end
    end

    sys.Log("Caller's number: '#{@cid}'"); sys.Log("Caller's name:   '#{@cname}'") if @cname
    incomingCall()        # forward incoming call

  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.split(':')[0]                 # Convert to lowercase and delete optional ":port"
    num << '@' << reqHost unless Domains.include?(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
by the way I want also to put a voip provider selection but with mexico but dont know regexp. in USA is this

when /(^1([2-9]\d\d)[2-9]\d{6})/ # North America
@num = $1 # Truncate to 11 digits

but in mexico is this way format 52 (xx) xxxxxxxx (country 52 + 2 digit area (xx) + 8 digits Phone xxxxxxxx and need to truncate to 8 digits since the area I dial has is own local phone


thanks for all. and help

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: **Error: Can't convert VSP into Fixnum

Post by MikeTelis » Tue May 10, 2011 10:07 am

Could you please post Console log of a failed GV call here?

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: **Error: Can't convert VSP into Fixnum

Post by qubo » Tue May 10, 2011 5:18 pm

yes sure the console show this by the way I hide 3 digits of the phone. I call from my NY phone to a phone in Dallas and to go thru my gv in new york I set prefix *#1

Code: Select all

NATKeepAlive 17:18:00:368 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65410.
NATKeepAlive 17:18:00:446 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65240.
DialPlan 17:18:02:587 sip1(11048): New call from udp:187.133.147.183:65410 successfully authenticated by digest.
DialPlan 17:18:02:603 sip1(11048): Using dialplan miketelisOUT for Out call to sip:*#121481xxx43@sipsorcery.com.
NewCall 17:18:02:634 sip1(11048): Executing script dial plan for call to *#121481xxx43.
DialPlan 17:18:02:759 sip1(11048): ** Call from <sip:IPOD@sipsorcery.com>;tag=33822EFA9D4AE522DFA47C8C6A4FA428 to *#12148101343 **
DialPlan 17:18:02:759 sip1(11048): Local time: 05/09/2011 22:18
DialPlan 17:18:02:790 sip1(11048): Number in ENUM format: 121481xxx43
DialPlan 17:18:02:821 sip1(11048): Calling +1 (214) 81x-xx43 (Forced routing!) with GV-646
DialPlan 17:18:02:868 sip1(11048): ** Error: can't convert VSP into Fixnum
DialPlan 17:18:02:868 sip1(11048): Dialplan cleanup for yyyuba.
DialPlan 17:18:03:056 sip1(11048): Dial plan execution completed without answering and with no last failure status.
DialPlan 17:18:03:056 sip1(11048): UAS call failed with a response status of 480.
NATKeepAlive 17:18:05:587 sip1(3436): Requesting NAT keep-alive from proxy socket tcp:69.59.142.213:2060 to tcp:187.133.147.183:57849.
NATKeepAlive 17:18:05:649 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65202.
NATKeepAlive 17:18:10:712 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65410.
NATKeepAlive 17:18:10:805 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65240.

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: **Error: Can't convert VSP into Fixnum

Post by MikeTelis » Wed May 11, 2011 1:28 pm

The error wasn't easy to spot! Here it is:

Home = VSP.new '#4', ' ${EXTEN}@Home', 'Casa route'

What happened, you've redefined constant "Home" which is used (as well as "Work", "Mobile", "Gizmo") to specify callback type for sys.GoogleVoiceCall. You need to use any other name, such as "Home1", or "Casa" and the error will go away.

I also have to say that you need to get rid of:

Myacnt1 + { :cb => 'nil' },

(just delete this and the other line with similar code completely).

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: **Error: Can't convert VSP into Fixnum

Post by qubo » Wed May 11, 2011 4:03 pm

thanks so muck Mike I did what you said and It works fine. thanks

By the way. I have 2 questions

1- What do I need to change in order that use your dialplan to work with mexico instead of USA. in area if I put 33 that is my area en mexico. it prepend 1 that is USA and mexico should be 52 so my local calls depend of the country 52 and zone 33. in USA is 7 digits, in mexico is 8 Digits so +52 (33) 12345678. it does not matter If I deativated all USA and make only dial to USA when using prefix like *#1

second question

2- this is about incoming call and CID prefix I want all the sip providers has their own prefix I did what you said example in provider Mont I put contact in sip provider as this sip:Mont.inquss@sipsorcery.com being inquss the sip account the device is registerd. and Mont the prefix to see what DID is incoming, the problem is that in my Phone screen does not appears the Mont. prefix and I dont know why so I can not see the DID the call is from. and the number that show is reformarted to 1 (xxx) xxxxxxxx that is in the US format. so the question here is how to make it work the prefix CID and change the formart like this
Mont (xx) 12345678 thanks for all your help and thanks for the fix on the other question

qubo

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: **Error: Can't convert VSP into Fixnum

Post by MikeTelis » Wed May 11, 2011 6:05 pm

Hi Qubo,

in order to customize the dialplan for Mexico you'll need to change to_ENUM() method so that it would convert "Mexico" numbers into ENUM format. Besides, it's necessary to make changes to formatNum() method (inside 'mikesgem') so that it would properly format Mexico numbers.

The latter is definitely my job and I'll try to have it done a.s.a.p.

As to incoming calls, you'll need to modify incomingCall() method and/or the "In" part of the main. I can't be more specific before I see what you actually get from your DID provider; please give me a few samples of the Console log for incoming calls. The calls should be coming from different sources (landline, mobile), preferably from different area codes within the country. You don't need to answer incoming calls (and waste the caller's money); I only need to take a look at CIDs delivered by your DID provider(s).

I will try my best to help you. Unfortunately, the information about Mexico numbering plan is scarce and contradictory. Please clarify some points for me:

1. Did I get it right that most of the cities in Mexico use 3-digit area code? Exceptions: 33, 55, 81 and 1 - mobile numbers.
2. How do you properly format phone numbers? Please give me a couple of examples, like:

+52 33 1234-5678

3. Do you always have to dial national number of you can dial 7 or 8-digit numbers when calling within the same area?
4. Is 0 your long-distance prefix?
5. What is your international prefix?

Sincerely,

Mike

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: **Error: Can't convert VSP into Fixnum

Post by qubo » Wed May 11, 2011 9:50 pm

Re: **Error: Can't convert VSP into Fixnum

Postby MikeTelis » Wed May 11, 2011 12:05 pm
Hi Qubo,

in order to customize the dialplan for Mexico you'll need to change to_ENUM() method so that it would convert "Mexico" numbers into ENUM format. Besides, it's necessary to make changes to formatNum() method (inside 'mikesgem') so that it would properly format Mexico numbers.

The latter is definitely my job and I'll try to have it done a.s.a.p.

As to incoming calls, you'll need to modify incomingCall() method and/or the "In" part of the main.

Code: Select all

 Here I dont know what to modify and I didnt found any part that said main
I can't be more specific before I see what you actually get from your DID provider; please give me a few samples of the Console log for incoming calls. The calls should be coming from different sources (landline, mobile), preferably from different area codes within the country. You don't need to answer incoming calls (and waste the caller's money); I only need to take a look at CIDs delivered by your DID provider(s).

Code: Select all

 
here is one with Cid Prefix Casa

NATKeepAlive 00:17:36:063 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65249.
NATKeepAlive 00:17:36:063 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65246.
DialPlan 00:17:36:391 sip1(8220): Using dialplan Incoming ALL for In call to sip:Casa.inquba@sipsorcery.com;rinstance=437972.
NewCall 00:17:36:406 sip1(8220): Executing script dial plan for call to Casa.inquss.
DialPlan 00:17:36:453 sip1(8220): Commencing Dial with: inquss@local&IPOD@local&portech@local.
DialPlan 00:17:36:469 sip1(8220): Call leg is for local domain looking up bindings for inquss@sipsorcery.com for call leg inquba@local.
DialPlan 00:17:36:500 sip1(8220): 1 found for inquss@sipsorcery.com.
DialPlan 00:17:36:531 sip1(8220): Call leg is for local domain forwarding to incoming dialplan for IPOD@sipsorcery.com.
DialPlan 00:17:36:547 sip1(8220): Call leg is for local domain looking up bindings for portech@sipsorcery.com for call leg portech@local.
DialPlan 00:17:36:563 sip1(8220): 1 found for portech@sipsorcery.com.
DialPlan 00:17:36:563 sip1(8220): ForkCall commencing call leg to sip:inquss@187.133.147.183:65246.
DialPlan 00:17:36:563 sip1(8220): ForkCall commencing call leg to sip:IPOD@local.
DialPlan 00:17:36:563 sip1(8220): ForkCall commencing call leg to sip:portech@187.133.147.183:65249.
DialPlan 00:17:36:578 sip1(8220): SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 00:17:36:578 sip1(8220): Switching to sip:inquba@187.133.147.183:65246 via udp:69.59.142.213:5060.
DialPlan 00:17:36:578 sip1(8220): Creating B2B call for sip:IPOD@local.
DialPlan 00:17:36:578 sip1(8220): SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 00:17:36:578 sip1(8220): Switching to sip:portech@187.133.147.183:65249 via udp:69.59.142.213:5060.
DialPlan 00:17:36:641 sip1(8220): Using dialplan OUTGrace for In call to sip:IPOD@local.
NewCall 00:17:36:641 sip1(8220): Executing script dial plan for call to IPOD.
DialPlan 00:17:36:813 sip1(8220): ** Call from <sip:inquss@sipsorcery.com>;tag=1975715268 to IPOD **
DialPlan 00:17:36:813 sip1(8220): Local time: 05/11/2011 05:17
DialPlan 00:17:36:828 sip1(8220): Caller's number: 'inquss'
DialPlan 00:17:36:891 sip1(8220): Dialplan cleanup for inquss.
DialPlan 00:17:36:938 sip1(8220): Information response 100 Trying for sip:inquss@187.133.147.183:65246.
DialPlan 00:17:36:953 sip1(8220): Dial plan execution completed with normal clearing.
DialPlan 00:17:37:078 sip1(8220): Information response 180 Ringing for sip:inquss@187.133.147.183:65246.
DialPlan 00:17:37:078 sip1(8220): UAS call progressing with Ringing.
DialPlan 00:17:38:172 sip1(8220): Information response 100 Trying for sip:portech@187.133.147.183:65249.
DialPlan 00:17:38:266 sip1(8220): Information response 180 Ringing for sip:portech@187.133.147.183:65249.
DialPlan 00:17:38:266 sip1(8220): UAS call ignoring progress response with status of 180 as already in Proceeding.
NATKeepAlive 00:17:41:188 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65288.
NATKeepAlive 00:17:41:203 sip1(3436): Requesting NAT keep-alive from proxy socket tcp:69.59.142.213:2060 to tcp:187.133.147.183:57285.
DialPlan 00:17:41:797 sip1(8220): Client call cancelled halting dial plan.
DialPlan 00:17:41:797 sip1(8220): Dialplan call was terminated by client side due to ClientCancelled.
DialPlan 00:17:41:797 sip1(8220): Cancelling all call legs for ForkCall app.
DialPlan 00:17:41:797 sip1(8220): Cancelling forwarded call leg, sending CANCEL to sip:inquss@187.133.147.183:65246.
DialPlan 00:17:41:797 sip1(8220): Cancelling forwarded call leg, sending CANCEL to sip:portech@187.133.147.183:65249.
DialPlan 00:17:41:797 sip1(8220): Dial command was halted by cancellation of client call after 5.23s.
DialPlan 00:17:41:797 sip1(8220): Dialplan cleanup for inquba.
DialPlan 00:17:41:984 sip1(8220): Dial plan execution completed with normal clearing.
DialPlan 00:17:42:078 sip1(8220): Response 487 Request Terminated for sip:inquss@187.133.147.183:65246.
DialPlan 00:17:42:250 sip1(8220): Response 487 Request Terminated for sip:portech@187.133.147.183:65249.

here is other CID prefix Casa
25:304 sip1(14676): Using dialplan Incoming ALL for In call to sip:Casa.inquss@sipsorcery.com;rinstance=437972.
DialPlan 22:28:25:319 sip1(14676): Using dialplan Incoming ALL for In call to sip:inquss@sipsorcery.com;rinstance=102707.
NewCall 22:28:25:319 sip1(14676): Executing script dial plan for call to Casa.inquss.
NewCall 22:28:25:335 sip1(14676): Executing script dial plan for call to inquss.
DialPlan 22:28:25:382 sip1(14676): Commencing Dial with: inquss@local&IPOD@local&portech@local.
DialPlan 22:28:25:397 sip1(14676): Commencing Dial with: inquss@local&IPOD@local&portech@local.
DialPlan 22:28:25:413 sip1(14676): Call leg is for local domain looking up bindings for inquss@sipsorcery.com for call leg inquss@local.
DialPlan 22:28:25:413 sip1(14676): Call leg is for local domain looking up bindings for inquss@sipsorcery.com for call leg inquss@local.
DialPlan 22:28:25:444 sip1(14676): 1 found for inquss@sipsorcery.com.
DialPlan 22:28:25:444 sip1(14676): 1 found for inquss@sipsorcery.com.
DialPlan 22:28:25:475 sip1(14676): Call leg is for local domain forwarding to incoming dialplan for IPOD@sipsorcery.com.
DialPlan 22:28:25:491 sip1(14676): Call leg is for local domain forwarding to incoming dialplan for IPOD@sipsorcery.com.
DialPlan 22:28:25:522 sip1(14676): Call leg is for local domain looking up bindings for portech@sipsorcery.com for call leg portech@local.
DialPlan 22:28:25:569 sip1(14676): 1 found for portech@sipsorcery.com.
DialPlan 22:28:25:569 sip1(14676): ForkCall commencing call leg to sip:inquss@187.133.147.183:65202.
NATKeepAlive 22:28:25:600 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65249.
DialPlan 22:28:25:600 sip1(14676): ForkCall commencing call leg to sip:IPOD@local.
DialPlan 22:28:25:600 sip1(14676): SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 22:28:25:647 sip1(14676): ForkCall commencing call leg to sip:portech@187.133.147.183:65249.
DialPlan 22:28:25:647 sip1(14676): Switching to sip:inquba@187.133.147.183:65202 via udp:69.59.142.213:5060.
DialPlan 22:28:25:663 sip1(14676): Creating B2B call for sip:IPOD@local.
DialPlan 22:28:25:663 sip1(14676): SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 22:28:25:663 sip1(14676): Switching to sip:portech@187.133.147.183:65249 via udp:69.59.142.213:5060.
DialPlan 22:28:25:694 sip1(14676): Call leg is for local domain looking up bindings for portech@sipsorcery.com for call leg portech@local.
DialPlan 22:28:25:710 sip1(14676): Using dialplan OUTGrace for In call to sip:IPOD@local.
DialPlan 22:28:25:710 sip1(14676): 1 found for portech@sipsorcery.com.
DialPlan 22:28:25:710 sip1(14676): ForkCall commencing call leg to sip:inquss@187.133.147.183:65202.
DialPlan 22:28:25:710 sip1(14676): ForkCall commencing call leg to sip:IPOD@local.
DialPlan 22:28:25:710 sip1(14676): ForkCall commencing call leg to sip:portech@187.133.147.183:65249.
DialPlan 22:28:25:710 sip1(14676): Creating B2B call for sip:IPOD@local.
DialPlan 22:28:25:725 sip1(14676): SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 22:28:25:710 sip1(14676): SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 22:28:25:741 sip1(14676): Switching to sip:inquss@187.133.147.183:65202 via udp:69.59.142.213:5060.
DialPlan 22:28:25:725 sip1(14676): Switching to sip:portech@187.133.147.183:65249 via udp:69.59.142.213:5060.
NewCall 22:28:25:741 sip1(14676): Executing script dial plan for call to IPOD.


is with cid prefix nextel. the call does not sound  and hangup fast plus it was added the number 1 of USA

NATKeepAlive 22:17:51:238 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65249.
NATKeepAlive 22:17:51:253 sip1(3436): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.147.183:65202.
DialPlan 22:17:53:863 sip1(14676): Using dialplan OUTGrace for In call to sip:nextel.IPOD@sipsorcery.com;rinstance=600110.
NewCall 22:17:53:878 sip1(14676): Executing script dial plan for call to nextel.IPOD.
DialPlan 22:17:54:097 sip1(14676): ** Call from <sip:3339490009@200.76.112.13:5060;user=phone>;tag=1fcfeb8-21724cc8-13c4-67c93-7ad5c308-67c93 to nextel.IPOD **
DialPlan 22:17:54:097 sip1(14676): Local time: 05/11/2011 03:17
DialPlan 22:17:54:206 sip1(14676): WebGet attempting to read from http://query.yahooapis.com/v1/public/yql?q=select * from xml where url='http://api.whitepages.com/reverse_phone/1.0/?phone=3339490009;api_key=427961d1960ac97d0799e6562bbc3bd9' and itemPath='wp.listings.listing'&format=json.
DialPlan 22:17:54:784 sip1(14676): Caller's number: '13339490009'
DialPlan 22:17:54:784 sip1(14676): UAS call failed with a response status of 480 and IPOD is asleep.
DialPlan 22:17:54:800 sip1(14676): Dialplan cleanup for inquss.
DialPlan 22:17:55:284 sip1(14676): Dial plan execution completed with normal clearing.
NATKeepAlive 22:17:56:363 sip1(3436): Requesting NAT keep-alive from proxy socket tcp:69.59.142.213:2060 to 
I will try my best to help you. Unfortunately, the information about Mexico numbering plan is scarce and contradictory. Please clarify some points for me:

1. Did I get it right that most of the cities in Mexico use 3-digit area code? Exceptions: 33, 55, 81 and 1 - mobile numbers.

Code: Select all

YES IN MEXICO ALL ARE 3 DIGITS EXCEPT 33 55 and 81 That are the major cities Guadalajara, Mexico DF and Monterrey you are right other cities in mexico are (123) 1234567 for mobile phone this is 1 is only when some people in other country want to call a mobile 52 (1) (area) mobile number(10 Digits). for  Mexico National calls to mobile are without 1 but Local calls to mobiles are 044 + cellphone (cellphone are 10 digits )that are in area, but If I want to make a call to a mobile in other city then i need to use code 045 + cellphone (10 digis)

2. How do you properly format phone numbers? Please give me a couple of examples, like:

+52 33 1234-5678

Code: Select all

Usually when a Incoming call the phone Display put this format 3312345678 without the +52 country code so all incoming calls no matter what city is coming it show all togheter so it only show 10 digits but it could be fine if the area code could be splited example  (81) xxxx-xxxx (33) yyyy-yyyy (55) xxxx-xxx and all others (342) xxx-xxxx
3. Do you always have to dial national number of you can dial 7 or 8-digit numbers when calling within the same area?

Code: Select all

When I dial in the same area you only need to dial the 8 digits in my case is area 33 for guadalajara so I only need to dial 8 digits if other zone then local calls are 7 digits Note for Local you dont need to dial country code 52 and not area code so only digitis for local
4. Is 0 your long-distance prefix?

Code: Select all

If I do  a national call. I need to dial 01 then area code and then the 8 digits or 7 digits  example   015512345678 will dial from any city in mexico to mexico DF if I dial 018112345678 any city to MOnterrey and if other city in mexico 013421234567 a national call to a city with area code of 3 digits (123).
5. What is your international prefix?

Code: Select all

For a Internacional call the code is 001 so If I want to call argentina that is 54 area then I dial 00154(xxx)xxxx

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: **Error: Can't convert VSP into Fixnum

Post by MikeTelis » Thu May 12, 2011 3:32 am

I used this article as a reference. It more or less corresponds to what you said but there are some discrepancies:

1. Long-distance prefixes are either 01 or 02.
2. International prefixes are either 00 or 09 but not 001.
3. There are 2 special prefixes for mobile phones, 044 and 045.

Please double-check!

Okay, let's go step-by-step. I have written and tested the following code:

Code: Select all

# **************************  t o   E N U M  *******************************

INTERNATIONAL = /^(\+|00|09)/
LONGDISTANCE  = /^(01|02)(\d{10})$/
MOBILE        = /^(044|045)(\d{10})$/
LOCALCALL	  = /^\d{#{10-Area.length}}$/

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

  # Check if the number begins with one of international prefixes:
  #  '+' - international format
  #   00, 01 - direct/operator international dialing

  num =~ INTERNATIONAL and return $' # if yes, remove prefix and return

  case num              	  # Special cases
    when LOCALCALL			  # Local call
      Country + Area + num    # prefix it with country and area code
    when MOBILE				  # Mobile number
      Country + '1' + $2      # Country + '1' + national number
    when LONGDISTANCE		  # Mexico long distance
      Country + $2            # add country code
    when /^\*/                # Voxalot voicemail, echotest & other special numbers
      num                     # ... as is
    else
      rejectCall(603,"Wrong number: '#{num}', check & dial again")
  end
end
It works like this (dialed_number -> number_in_ENUM_format):

1234567 => Rejected with code 603 -- Wrong number: '1234567', check & dial again
12345678 -> 523312345678
013312345678 -> 523312345678
0445512345678 -> 5215512345678
0458112345678 -> 5218112345678
0012125551212 -> 12125551212

Please check if it's what you actually need. If you wish to incorporate this chunk of code into your dialplan, you need to replace to_ENUM with the above code. Besides, you'll need to add "Country" definition in the beginning of dialplan:

Code: Select all

Country = '52'		  # my country code
Area = '33'           # my area code
Note that to_ENUM always returns the number in ENUM (international) format. I hope that all your VSPs accept this format; if it's not the case, you can strip out country code in the VSP descriptor using $EXTEN optional parameters.

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: **Error: Can't convert VSP into Fixnum

Post by MikeTelis » Thu May 12, 2011 3:58 am

In pursuit: add the following code right after require 'mikesgem'. It will replace formatNum() sitting inside mikesgem; once we make sure that it properly formats Mexico numbers I'll ask Aaron to update mikesgem on Sipsorcery server.

Code: Select all

# *************************  f o r m a t N u m  ****************************

def formatNum(num,exact=false)
  case num
                   # Closed Numbering Plan
    when /^(39)(0[26]|0\d[0159]|0\d{3}|3\d\d)(\d*)(\d{4})$/,    # Italy: Milan, Rome, 0x0, 0x1, 0x5, 0x9, 4-digit
         /^(41|48)(\d{2})(\d{3})(\d{4})$/,       # Swiss, Poland
         /^(34)(9[1-9]|[5-9]\d\d)(\d{3})(\d{3,4})$/, # Spain
         /^(32)(4[789]\d|[89]0\d|[2-4]|[15-8]\d)(\d{3})(\d{3,4})$/, # Belgium
         /^(86)(1[2-9]\d)(\d{3,4})(\d{4})$/,     # China mobile
         /^(886)(37|49|89|\d)(\d*)(\d{4})$/,     # Taiwan
         /^(972)(\d{1,2})(\d{3})(\d{4})$/,       # Israel
         /^(31)(6|800|8\d|9\d\d)(\d*)(\d{4})$/   # Netherlands non-geo
      sep = $3[2] ? '-' : ''                     # separator if $3 group has 3 or more digits
      "+#$1 #$2 #$3#{sep}#$4"

                   # Open Numbering Plan
    when /^([17]|90)(\d{3})(\d{3})(\d{4})$/,     # USA, Russia, Turkey
         /^(61)(\d)(\d{4})(\d{4})/,              # Australia
         /^(49)(1[5-7]\d|30|40|69|89|\d\d1|\d{4})(\d*)(\d{4})$/, # Germany: (mobile|2dig|3dig|4dig) area
         /^(380|375|998)(\d{2})(\d{3})(\d{4})$/, # Ukraine, Belarus, Uzbekistan
         /^(370)(469|528|37|45|46|57|5|\d{3})(\d*)(\d{4})$/,    # Lithuania
         /^(36)(1|\d\d)(\d{3})(\d{3,4})$/,       # Hungary
         /^(86)(10|2\d|\d{3})(\d{3,4})(\d{4})$/, # China: Beijing, 2x, others 3-dig area code
         /^(91)(800|11|20|33|40|44|[789]\d|\d{3})(\d*)(\d{4})$/, # India
         /^(63)(2|[3-8]\d|9\d\d)(\d{3})(\d{4})$/, # Philippines (Manila, [3-8]x, 9xx - mobile)
         /^(81)(3|6|[2-9]0|\d\d0|\d\d)(\d*)(\d{4})$/, # Japan
         /^(55)(\d\d)(\d{4})(\d{4})$/,           # Brazil
         /^(31)(7\d|[1-5][035]|2[46]|3[68]|46|58|\d{3})(\d*)(\d{4})$/ # Netherlands geo
      sep = $3[2] ? '-' : ''                     # separator if $3 group has 3 or more digits
      "+#$1 (#$2) #$3#{sep}#$4"

    when /^(52)(1)?(33|55|81|\d{3})(\d*)(\d{4})$/ # Mexico
      "+#$1#{$2.nil? ? '' : ' ' + $2} #$3 #$4-#$5"
      
    when /^(33)(\d)(\d{2})(\d{2})(\d{2})(\d{2})$/ # France
      "+#$1 #$2 #$3 #$4 #$5 #$6"

    when /^(44)(11\d|1\d1|2\d|[389]\d\d)(\d{3,4})(\d{4})$/, # UK 2- and 3-digit area codes: 11x, 1x1, 2x, 3xx, 8xx, 9xx
         /^(44)(\d{4})(\d{3})(\d{3,4})$/        # UK 4-digit area codes
      "+#$1 (#$2) #$3 #$4"

    when /^(420)(\d{3})(\d{3})(\d{3})$/         # Czech Republic
      "+#$1 #$2 #$3 #$4"

    when /^(37[12])(\d{3,4})(\d{4})$/           # Latvia, Estonia
      "+#$1 #$2-#$3"

    when /^(373)([67]\d{2})(\d{2})(\d{3})$/     # Moldova mobile
      "+#$1 #$2-#$3-#$4"

    when /^(373)(22|\d{3})(\d{1,2})(\d{2})(\d{2})$/ # Moldova landline
      "+#$1 (#$2) #$3-#$4-#$5"

    when /^(1|2[07]|3[0-469]|4[^2]|5[1-8]|6[0-6]|7|8[1246]|9[0-58]|\d{3})/ # all country codes
      exact ? num : "+#$1 #$'"                  # the pattern used only if exact == false

    else num    # No match - skip formatting
  end
end

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: **Error: Can't convert VSP into Fixnum

Post by qubo » Thu May 12, 2011 5:04 am

I put the info about the incoming call for the cid prefix if you can check. and about your code I will test and tell you the result of testing. thanks

I double check the numbers so this are the final and correct


Large Distance national :
01 + area + phone
Estados Unidos o Canadá:
001 + area + phone (this is for USA and Canada only )
For the rest of the world from mexico:
00 + country code +area + phone

1 for cell is only used for foreign calls incoming to a mexican mobile this number 1 is not used when the call to mobile is inside mexico 52 1 3312345678

local calls can be made directly with 8 digits to 33,55,81 areas and for all others (123) 7 digits
to a local mobile is 044 + 10 digits
to a national mobile is 045 + 10 digits

for 02 is a national call but with assistence of operator (they charge extra )
for 09 is for internation call but with assicente of operator (they charge extra )
note: you can omit 02 and 09 because nobody use this because they charge.

Post Reply