CLI DialPlan Management

From FusionPBX
Revision as of 00:49, 21 October 2010 by Swilkey (talk | contribs) (Added entry)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Dial plans are complicated to understand. How can we see why things are failing to work the way we think they should?

CLI, the command line interface, is one of the most useful tools when it comes to understanding what is going on in your system. Here you can look in real time at what is happening when you try to make or receive a call and you can diagnose faults. I have to say that this has been the most useful piece of information when it comes to diagnosing issues with the dial plan (apart from learning to write regular expressions). To run the cli you type /usr/local/freeswitch/bin/fs_cli at the linux prompt. If you don't want to look real time you can also look at the logs in /usr/local/freeswitch/log/freeswitch.log. Note that if you are using the console of your server then you really need to be looking at the log as that way you'll be able to scroll back and forward using your text file viewer and see what you need to see. But if you use PUTTY you can use the cli as you'll be able to scroll back and forward using the scroll bar on the side of the putty window. Note that the putty line buffer is set to 200 lines by default - I tend to increase this to 2000 so that I have enough history to scroll back through.

When you are using the CLI you can exit the CLI back to the linux prompt by typing ... (yes, three fullstops in a row, or for Americans, 3 periods in a row). To diagnose dial plan faults, start the CLI and then dial the number you want to test using your phone. You will see a bunch of stuff flying past. You'll then hear your call failure (if you didn't have a call failure you wouldn't be diagnosing it would you...) and at that point press CTRL-S to freeze the CLI output until you are finished looking at it.

So you're looking at the log. Look for a line like this one: 2010-08-12 09:20:21.736881 [INFO] mod_dialplan_xml.c:331 Processing [THE NAME OF YOUR PHONE EXTENSION YOU DIALED FROM]->[THE NUMBER YOU DIALED] in context default It could be quite a way back up the log so don't give up looking. What happens after this is that you'll see a number of lines with the words "Regex (FAIL)" in them. This is not bad. What is happening is that your number is being compared to each regular expression in the dial plan in turn, and when it gets through the parts of the dial plan you have configured it then goes through the default dial plan (in dial plan, advanced) and compares each expression with your number. When it finds a match you will get a "Regex (PASS)". This pass is the key to diagnosing your problem. The thing about FusionPBX (maybe also Freeswitch for that matter) is that there are a LOT of functions already defined for you and they don't seem to have any sort of consistent pattern or number range that they are in (unlike Trixbox where you can see all of these in "Feature Codes" and most of them are * followed by a 2 digit number) therefore it is quite possible that what you are trying to set as your dial sequence is already matching one of the pre-defined functions and therefore it isn't working for you. It would also appear that some of these functions are defined in the dial plan BEFORE the things that you define in the dial plan, as putting your dial plan entry with an order of 0 still doesn't override them. So look at the PASS line and see which regular expression it matches, and the bits on the lines following that will give you clues as well. If it isn't the regular expression that you configured then it is likely you are in conflict with one of the already defined functions and you are just going to have to change yours.

The other possibility is that your regular expression is wrong - but you can test your regular expression with a number of automatic testing pages on the internet to see if that is the problem - the one I like is http://erik.eae.net/playground/regexp/regexp.html because you can cut and paste your regular expression into the first box, and then type your dial sequence into the second box, and then in real time, the third box gives you the interpreted result and even breaks it up into the different number groupings caused by your use of () in the regular expression.