Ruby Dial Plans

Support zone
jack9901
Posts: 277
Joined: Tue Jan 29, 2008 7:30 pm

Post by jack9901 » Thu Apr 03, 2008 12:27 am

Aaron wrote: I've encountered a snag getting regular expression strings from the Ruby script back to the sipswitch. The strings are not getting passed back literally and regex escape patterns are not making it through. The workaround is to use replace any case where normally \ would be used with \\.
I guess you probably use some program to preprocess the script before it is executed. I once had to use eight backslash \\\\\\\\ to make path names in Windows registry file to work because I used two programs to process the file and the registry file itself require double slash.

markcs
Posts: 42
Joined: Sat Feb 16, 2008 5:44 pm

Post by markcs » Thu Apr 03, 2008 11:15 am

Aaron wrote: The FromURI is a SIPURI object and has a string property called Host so you can use req.Header.From.FromURI.Host.
Thanks Aaron.. exactly what I was looking for.

voipuser
Posts: 14
Joined: Fri Nov 02, 2007 6:00 pm

Post by voipuser » Sat Apr 05, 2008 6:57 pm

Hi all,

I tried to test the sys.EnumLookup function but it didn't work. :cry:
According to the syntax and example Aaron gave and other (good, thks jack9901) tricks, I tried the following Dial Plan (to test with French phone numbers; get the 10 digits number, remove the fist one and add the international code for the Enum lookup) :

#Ruby
sys.Log("call received uri=#{req.URI.User}")
enumuri = sys.EnumLookup("+33#{req.URI.User.to_str[1..-1]}.e164.org")
if enumuri != nil
sys.Dial(enumuri)
else
sys.Respond(404, "ENUM lookup failed")
end

I tried with a phone numbe that is registered in e164.org (a test with enumquery.com works fine) but, in the monitoring, I get :

Dialplan load 0ms
call received uri=04xxxxxxxx (actual number hidden on purpose)
There was a missing method exception in your dial plan, please check.

I also tried with the phone number directly hard coded in the sys.Enumlookup function but same problem.

Has anyone else tested the ENUM lookup ?
Any idea of what might be wrong ?

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Sat Apr 05, 2008 10:23 pm

Hi voipuser,

I made a mistake in the documentation sorry. The method is ENUMLookup and not EnumLookup.

Regards,

Aaron

voipuser
Posts: 14
Joined: Fri Nov 02, 2007 6:00 pm

Post by voipuser » Sun Apr 06, 2008 1:58 pm

Hi Aaron

Still doesn't work.
Therefore, I tried this very basic Dial Plan :

#Ruby
enumuri=sys.ENUMLookup("+33400000000.e164.org")
if enumuri != nil
sys.Log("Found")
else
sys.Log("NOT found")
end

NB : actual number changed in this example for confidentiality purposes.

I always (tried "+33..." ; "0033..." ; "33...") get : "NOT found" while I get the SIP URI with enumquery.com.

What's wrong ? Is the syntax ".....e164.org" (my phone number is registered with e164.org) correct ?

Thanks in advance for your help.

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Sun Apr 06, 2008 10:39 pm

Hi voipuser,

If you can PM me your number I'll take a look.

The test number that I use is below (it's one I found on the web) and it's working fine.

enumURI = sys.ENUMLookup("43780004711.e164.arpa")

I also added a NAPTR ENUM record to the mysipswitch.com domain and am able to look that up as well.

Regards,

Aaron

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Wed Apr 09, 2008 6:31 am

Hi voipuser,

Your ENUM lookups should now work but due to teh regex patterns used by e164.org your number must be entered exactly as including the + sign:

enumuri=sys.ENUMLookup("+33400000000.e164.org")

There were a few differences between the way I was doing the matching compared to e164.org. They've been doing enum for a lot longer than me and their service is a lot more mature so I've adjsuted the sipswitch code to accomdate the way they are working.

Regards,

Aaron

voipuser
Posts: 14
Joined: Fri Nov 02, 2007 6:00 pm

Post by voipuser » Wed Apr 09, 2008 7:06 pm

Hi Aaron,

Yes, it is working much better now ! Thanks :D

However, it is working with the "hard coded" number but if I try this syntax :
enumuri = sys.ENUMLookup("+33#{req.URI.User.to_str[1..-1]}.e164.org")
I get in the Monitoring a : "There was a missing method exception in your dial plan, please check"

While at the same time, this works fine and display the right value:
sys.Log("Lookup : +33#{req.URI.User.to_str[1..-1]}")

How can I have this syntax working with the sys.ENUMLookup ?

Regards

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Wed Apr 09, 2008 11:28 pm

Hi voipuser,

The syntax below works fine for me. Is there somewhere else is your dialplan that could be causing that error?

enumuri = sys.ENUMLookup("+33#{req.URI.User.to_str[1..-1]}.e164.org")

The telnet console is a good place to troubleshoot dialplans it will display log messages in realtime.

Regards,

Aaron

voipuser
Posts: 14
Joined: Fri Nov 02, 2007 6:00 pm

Post by voipuser » Sat Apr 12, 2008 9:18 am

Oops, sorry, I made again the same mistake (EnumLookup rather than ENUMLookup) :oops:

However, the call doesn't get thru, I got a (voice message) "We're sorry, the number you have dialed cannot be connected, please try again".

I am wondering whether the provider I am calling to (Voxalot in this case) is accepting a SIP URI call from MySIPswitch.

I'd like to dial thru Voxalot.
With the "standard" sys.Dial, you can select you provider (for example sys.Dial("blueface"). How can you with the "ENUM sys.Dial" where the only parameter is the SIP URI to dial ?

Locked