Thursday, December 2, 2010

The Nov 30th break of Asterisk 1.8 w/ GV

On November 30th, Asterisk GV outbound dialing started breaking for people.  The cause was unknown, and it became more prevalent the next two days.

The symptoms are a continuous ringing for the outbound call with the following type of stuff in the logs:


[Dec  3 00:54:00] NOTICE[18023]: chan_gtalk.c:1942 gtalk_parser: Remote peer reported an error, trying to establish the call anyway

Inbound calls (including those initiated from the website) are still functional.  It's not clear what the cause is, but an issue has been filed with Asterisk upstream at https://issues.asterisk.org/view.php?id=18412

In the interim, I've come up with a way to fix the problem by reviving the old AGI dialer originally used with Asterisk 1.6, but reworking it to use Talk instead of Gizmo.

This involves some modifications to the dialplan to support using AGI instead.  If you don't already have AGI setup, here's the basics for that:

1) Install AGI support for Asterisk:

opkg install asterisk18-res-agi

2) Create the AGI directory

mkdir -p /usr/lib/asterisk/agi-bin/

3) Fetch the updated AGI script from http://arctangent.net/~superm1/agi/google-voice-dialout.agi and save it in /usr/lib/asterisk/agi-bin.  Modify it to include your login information for google.

cd /usr/lib/asterisk/agi-bin
chmod +x google-voice-dialout.agi

4) Modify your dialplan.

outbound
Instead of 
exten => _1NXXNXXXXXX,1,Dial(Gtalk/superm1/${EXTEN}@voice.google.com)
Make the line
exten => _+1NXXNXXXXXX,1,AGI(google-voice-dialout.agi)

inbound
Add the following two rules:
exten => superm1@gmail.com, 1, GotoIf(${DB_EXISTS(gv_dialout/channel)}?bridged)
exten => superm1@gmail.com, n(bridged),Bridge(${DB_DELETE(gv_dialout/channel)}, p)

This will bridge outgoing calls with an incoming dialback handler.

As previously, i'll post my updated configs to http://www.arctangent.net/~superm1/gv_configs/.  The way that i've implemented it is actually just a different AGI handler that's included.  So when regular talk support is restored (as mentioned in https://issues.asterisk.org/view.php?id=18412) then it's a one line change to re-enable the standard outbound talk handler.

19 comments:

  1. Mario:
    In order for the fix to work, do you need to install Python support? The previous way you don't need to.
    Also, the fix/hack is not included in you latest gv_configs, right?

    ReplyDelete
  2. twinclouds:
    Yeah you will need to have python installed. One of my previous blog posts talks about installing it so that you can get caller id support working properly with names, so it was already on my box.

    If python is too big for your install without usb root fs, you might be able to rework that script as perl or even sh.

    The fix/hack is in my gv_configs. Look at my includes for outbound dialing and you'll see that they're calling out to a different AGI section for the outbound rather than the GV standard outbound section.

    Also the google-in section now has a handler for the bridging.

    ReplyDelete
  3. Mario:
    Thank you. Now I see it. It was not there last night. Maybe I was too impatient :).
    I will try install the three python packages you mentioned in your caller ID blog. I have one router has 16 MB. Hopefully it will be sufficient. Otherwise, I will add more memory for rootfs as you have suggested.

    ReplyDelete
  4. I'm running PIAF Purple with Asterisk 18 (The Incredible PBX) - I made sure the repositories were in my install to grab the AGI stuff, but when I issue the command (CentOS) "yum install asterisk18-res-agi", as per your directions above, the terminal window tells me that there is "no package asterisk18-res-agi available" and nothing to do. I am not a Linux expert by any means... I know enough to get into trouble! (smile)

    ReplyDelete
  5. Ken:

    I believe on most full fledged distros the AGI support is built into the standard asterisk 1.8 packages. It's only separated here because there is so little space on OpenWRT devices that it actually makes sense to be selective about what modules you need.

    ReplyDelete
  6. Mario:
    I used your conf files and now everything works very well. The connection speed is almost as fast as Gtalk originally. As long as it works as it is, I am very happy. Hopefully the problem is just because Google is try to make "improvements" not purposely try to stop us to use it.
    Thank you Mario for coming up this ingenious scheme.
    As for Ken's question, the term "asterisk18" is only for Openwrt. I didn't see anywhere else using it. CentOS certainly will not recognize it.
    Now I will try to compile Asterisk 1.8 for my Dockstar. Hope I will eventually be able to accomplish it.

    ReplyDelete
  7. Thanks Mario! I'll see if I can follow the rest of your directions to get this to work.

    Twinclouds, the latest PIAF package (along with "The Incredible PBX") claims it has Asterisk 18 in it which integrates GV.

    http://nerdvittles.com/?p=705

    When I first had it running, it worked fine on a virtual machine. Then that change came ~12/1 and dialing out ceased to function.

    ReplyDelete
  8. Ken:
    Which virtual machine you are using? I had earlier version working on my Acer R1600 Windows XP VM Player working but never got it installed for the latest one.
    I like Mario's implementation on OpenWRT because the router are cheaper (~$50) and consumes much less power (3W). Just not sure how secure it would be. Interface is not as easy to handle than FreePBX but should be manageable, especially just for GV uses.

    ReplyDelete
  9. Hi TwinClouds - I am using Oracle's VirtualBox. With a bridged network as the preferred, I do not have to worry about dual NATting.

    I picked up a Seagate Dockstar planning to put OpenWRT on it and Asterisk, but it's quite a daunting task.

    Which router are you using? I have a bunch of WRT54Gs around - a v3, v4 & GL. Also a Netgear WNR3500L - I *wish* I could install to one of those.

    I already have a pretty powerful machine at home which runs 24/7 so a virtual machine is no real cost.

    ReplyDelete
  10. Hi Mario - pardon my ignorance, but which file do I modify to change the dialplan to follow your directions above?

    I tracked down the extensions.conf file (if that's the one I need to change?) and it had nothing in it that mentioned Gtalk or had

    exten => _1NXXNXXXXXX,1,Dial(Gtalk/superm1/${EXTEN}@voice.google.com)

    in it.

    Sorry for my noobism. From what I have read, the extensions.conf file contains the dialplan.

    ReplyDelete
  11. Hi Ken,
    You're correct that the dialplan is in extensions.conf. Each of my blog posts is written iteratively for things that changed from the previous one.

    If you're missing stuff that I did in the previous one (as you might have a different starting point), feel free to reference my configs. My dialplan is included there too.

    http://www.arctangent.net/~superm1/gv_configs/

    ReplyDelete
  12. Thanks Mario. I am using the pre-built PIAF stuff with the Incredible PBX - it's set up differently. Perhaps now's the time to play with other options, like yours! A tip of the hat...

    ReplyDelete
  13. Hi, Ken:
    I used the packages generated by Mario for Asterisk 1.8. As I remember, they can be used for either ar71xx or brnc 2.4 Openwrt builds. You can check the Openwrt WIKI to fine if yours fit either one. In order for the router to implement the basic asterisk 1.8, it will need 8 MB internal flash. It will not be sufficient for add python so you probably need at least 16 MB. I am using one Buffalo that has 32 MB ram so that's not a problem. Otherwise, you will need to install on external USB drive as Mario suggested. Of course, the router has to have an USB port. I don't know what is the ram requirement. So far, it is not a problem.
    I will try Virtual box to see if it works.

    ReplyDelete
  14. Mario:
    I installed a few asterisk 1.8 packages as you suggested. It works well previously and also when using the agi/python scripts you provided. Now I try to use the non-python scripts to save memory (http://www.dslreports.com/forum/r25146039-Asterisk-GV-outgoing-calls-with-Asterisk1.8~start=20). However, when I integrated the scripts, it says "System command not found". Maybe the system command is in the package that I didn't install. Do you know which package that I might need to install to make it work? Thanks.

    ReplyDelete
  15. Ken Peterson:
    Great! Hope you got things sorted out. You might consider blogging or documenting somewhere what you had to do to make things work with PIAF.

    twinclouds:
    The way that shell script is integrated isn't properly using the AGI system. You'll need to do a bit of hacking on it to make it work with AGI. Particularly, agi feeds the channel and dnid information on stdin when it executes a script. So you'll want to set up the shell script to read and use the values listed there.

    If you really want to use the system call to do it, you are missing the asterisk18-app-system package. Not sure what else you'll be needing, but that should get you started.

    ReplyDelete
  16. Mario:
    In installed the asterisk18-app-system package. The shell script is working. Unfortunately, the set-up is not working correctly as you said. I have to hang up the call and wait for it rings back to complete the call. I just don't know enough to hack it. Oh, well.
    At least, every thing is working fine with the using the agi/python script you provided.

    ReplyDelete
  17. Cohete:

    The method detailed above is no longer necessary with the updated blog posts that have come after it.

    ReplyDelete
  18. I learned a very good lesson from this article. I really like this website and hope you will write more. Thanks a lot for your information. power dialer

    ReplyDelete