How to force FreePBX to immediately retry the same trunk again if it fails the first time even though the FreePBX developers apparently don’t want you to be able to do that

 

Important
This is an edited version of a post that originally appeared on a blog called The Michigan Telephone Blog, which was written by a friend before he decided to stop blogging. It is reposted with his permission. Comments dated before the year 2013 were originally posted to his blog.

This is going to be a very barebones explanation because to be honest I’m really not motivated to make things easier for FreePBX users anymore.  I really want you to think about trying other PBX software that doesn’t treat its users as if they need afternoon naps and their diapers changed occasionally.

But I have found a way to overcome the limitation, however you need Webmin or phpMyAdmin, and you need to be very careful because one wrong click could screw up your database.  I use Webmin so that’s what I’ll be talking about here.  I am NOT telling you to do this on your system, and if you should choose to follow my example and mess up your system, don’t email me about it because I can’t help you and I’m warning you that this might be dangerous if you don’t know what you are doing, and I will not assume any responsibility for what you choose to do.  You break it, you own all the parts.  Also note that I’m doing this on an FreePBX 2.8 system, so if you are using another version, things might be different from what I’m describing.  This is what I have done that worked for me; it may or may not work for you, but if you wish to attempt it I strongly recommend that you make sure you have a full system backup (MondoRescue is a good program to use to create such a backup).

In Webmin, go into Servers | MySQL Database Server and in the MySQL Databases section, click on the icon or label (NOT the checkbox) for asterisk.

On the next page, you may get a message saying “There are too many tables to display. Find tables matching” followed by a search field.  If so, enter the word “Outbound” and click “Search”.

Click on the icon or label (NOT the checkbox) for outbound_route_trunks

At this point, if your browser supports it, duplicate the tab so you have two tabs showing this page.  In the first, click the Export as CSV button and in the next page, select “Yes” for “Include column names in CSV?“and select “Display in browser” as the Export Destination and then click Export Now.  You should see a display showing your Outbound Routes, but since they are all identified by numbers, you won’t know which is which.  Leave this tab open and do not reload it.  This is a “snapshot” of your Outbound Route trunk selections as the database sees them, before you make any changes.

Now open another browser tab and go to the Outbound Route page for the route where you want to select the same trunk twice.  In the Trunk Sequence for Matched Routes section, where you’d add the desired trunk the second time, add ANY other trunk instead, and Submit Changes, but don’t click the orange bar to apply the configuration changes.  Do make sure that everything is correct in the route configuration because after you finish this you won’t be able to make any changes without repeating all these tedious steps, which would be totally unnecessary if… never mind.  And make a mental note of the total number of trunks in the list, and don’t make any changes to any other Outbound Routes until you’ve completed this process. EDIT: Also, while that same Outbound Route page is open, look at your browser’s URL bar and note the address that is open — that may include the route_id number that will be needed in the next step. For example, if the address is https://your.server.address/admin/config.php?display=routing&extdisplay=21 then 21 is most likely the route_id number.

Now go back to the duplicated Webmin tab (the one NOT showing the CSV display), and click View Data. Under route_id, each outbound route is identified by a number, and the number of times that number appears equals the number of trunks in the Trunk Sequence for Matched Routes section,  Note that if there are more than 25 entries you may have to page through them to find the route you are trying to change.  So, let’s say that your Outbound Route originally had one trunk selection, and you added the second one which is incorrect, just to force FreePBX to accept it, so there is now a total of two trunks for that route.  You’d look through the route_id’s to find one where the route_id number is listed twice (as many times as the number of trunk selections) and note the route_id number.  You would then flip back to the other tab showing the CSV output to see if that route was only listed once (only had one trunk selected) when you took the CSV “snapshot”.  If so, you have found the correct route; if not, keep looking.

The trunk order is determined by the number in the seq column and is zero based, so if you had two trunks total, and the first trunk was correct and the second was the incorrect trunk that you added, then look for the line with the correct route_id number and 0 in the seq column, and note the trunk_id for that line.  Now find the line with the same route_id number but with 1 in the seq column.  Make a mental note of the trunk_id so you can change it back if you somehow managed to get the wrong route, and click the checkbox at the start of the line and then click Edit Selected Rows.  That row should turn into text boxes and what you want to do is change the trunk_id so that it matches that of the trunk selection you want to duplicate (the one with 0 in the seq column in this example).  Click Save.

Go back to the Outbound Route page and do not click Submit Changes.  Instead, reload the page, or go to another Outbound Route and come back.  It should show the duplicated trunk where the incorrect trunk selection was.  Once again, do not click Submit Changes, but NOW you can click the orange bar to apply the configuration changes. Remember that if you EVER click “Submit Changes” on this page from now on, the duplicated trunk will be removed and you get to do this all over again (unless you can figure out how to modify the source code so it doesn’t do that). 🙁

If you use phpMyAdmin you should be able to do something similar.  Just remember that every time you need to go through this tedious procedure, you can silently “thank” the FreePBX developers for once again making the extra effort to make life difficult for their experienced users.

If you’ve somehow managed to screw up your system by doing this (and I hope you don’t), just remember I warned you that doing this could be dangerous, but on the flip side, now would be a really good time to try some other software (you could try FusionPBX, for example).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.