Category Archives: Asterisk

Asterisk OpenSource PBX

Listening to Asterisk voicemail e-mails on an Android phone

One of the easiest ways to listen to new voicemails is to get Asterisk/FreePBX to e-mail them to you as an attachment. One downside of this is that if you try to listen to them on your mobile phone they will play via the speaker. This makes it tricky to listen to them discreetly!

For Android there’s a little App called Earpiece that allows you to specify that media is played through the earpiece, rather than the speaker. This is quick to switch on temporarily while listening to the voicemail. It may be hardware dependent, but it works fine on my OnePlus One.

Android Earpiece   Android Earpiece

Monitoring your Peers (Asterisk extensions) and Trunks

As an admin for a telephone system, possibly one of the most useful things you can do is monitoring your peers and trunks. There are 2 great reasons you should do so:

1. You can respond to and resolve issues with your system before your users know about it, and you can be in the know if someone reports “none of the phones are working” when in fact only 1 or 2 are not working

2. You can actually know when there is a problem with the system – where you otherwise might not know there is a problem until someone calls on your mobile to say your office number is not working

 

I have 2 scripts running every 15 minutes to email me with the details of any down extensions and trunks. This is done in Crontab with the line:

*/15 8-18 * * Mon-Fri /usr/Peermonitor.sh

and similar for Trunkmonitor.sh. This line says to run every 15 minutes between 08:00 and 18:00 every Monday-Friday

Continue reading

Posting Asterisk/FreePBX calls to Toggl

Toggl is a hosted time tracking system, used to keep track of time spent of different projects.

If you use Asterisk/FreePBX and spend time on the phone to clients that should be assigned to a project you can automatically create time entries in Toggl using their API. To do this we can make a curl call from Asterisk when a call ends.

To be able to do this you’ll need to ensure you have curl compiled in to Asterisk. You can check this with “core show function CURL”.

I tested this on Asterisk 11 and FreePBX v2.11, but it should work the same on other versions.

First we need to add a little dial plan code to Asterisk to tell it to run our script when a call ends. We going to do this by adding the following lines to – /etc/asterisk/extensions_custom.conf

[macro-dialout-trunk-predial-hook]    ; check to ensure this context doesn't already exist before adding
exten => s,1,Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)

[hangup-handler]
exten => s,1,Noop( capsule crm intergration ${CALLERID(all)})
exten => s,n,Set(foo=${CURL(http://127.0.0.1/toggl.php?strSrc="${CDR(src)}"&strDst=${CDR(dst)}&strDuration="${CDR(duration)}")})
exten => s,n,Noop(${foo})
exten => s,n,Return()

Continue reading

Posting Asterisk/FreePBX CDRs as a task in Capsule CRM

I was recently talking to someone that was looking at running Capsule CRM.

In Capsule you can create a “Task” which is something that has happened or will happen. These “Tasks” can then be assigned to a customer or contact.

Capsule has an API that allows automating posting of these tasks and we can use CURL in Asterisk to post the call details.This guide was written using Asterisk 11. If this doesn’t work for you ensure you have curl compiled in to Asterisk with “core show function CURL”.

First we need to tell Asterisk to run a command when a call ends. We are going to do it at the end so that we can get the length of the call. FreePBX allows for this using a hangup-handler.

We are going to add the following lines to – /etc/asterisk/extensions_custom.conf

[macro-dialout-trunk-predial-hook]    ; check to ensure this context doesn't already exist before adding
exten => s,1,Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)

[hangup-handler]
exten => s,1,Noop( capsule crm intergration ${CALLERID(all)})
exten => s,n,Set(foo=${CURL(http://127.0.0.1/capsule.php?strCallid="${CALLERID(num)}"&strDuration="${CDR(duration)}")})
exten => s,n,Noop(${foo})
exten => s,n,Return()

Continue reading

Routers with SIP, NAT and ALGs

Getting some routers working with VOIP can be a pain. The problem is caused by NAT, and the translation of a private IP address (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) in to a IP address that works on the internet.

This is difficult with SIP/VOIP because IP addresses are not only included in the packet header, but also inside the packet itself. There are various methods that can be used to try and resolve this issue, and various places that ‘fixes’ can try and work.

The issue is this …

  • a local device (phone) sends a SIP packet to a device on the internet (Asterisk)
  • this packet will include local IP addresses in it but the Asterisk server needs to respond to the public address

There are a few different methods to try and ‘fix’ the issue

  • the phone uses STUN/ICE and tries to replace the private IP with the public IP in the packets it sends
  • the broadband firewall includes rules (a SIP ALG) to modify the packet as it’s forwarded
  • Asterisk tries to fix the issue by seeing where the packet came from (source address) and using that to modify the SIP packets

The 3 things working above can cause chaos, and failed calls!

The most difficult to troubleshoot is the firewall SIP ALG one as a packet will go in from the local network, some changes will be made!, and then the packet will be forwarded to the internet device. Some routers do a better job making changes to the packets than others.

I came across a great list written by Vonage including many routers and steps that can be taken to try and get them working with VOIP/SIP – https://support.vonagebusiness.com/app/answers/detail/a_id/21546

didlogic

Setting up a trunk to a SIP call provider in Asterisk can be a pain. Even for me – and I do it a lot!

When we set up a SIP call provider in Asterisk (a SIP trunk) and send calls to them our Asterisk server will send the call provider a SIP INVITE. Their system could respond in many different ways – decline the call, ask for user info, silently drop the call, process the call ….

Sometimes the call provider will send back information in the SIP reply as to why the call has failed. Maybe you have no credit, maybe the codec is not supported, maybe you have the number in the wrong format … but often they will not, they will just not process the call and send back a generic response.

At this point you need some help from the call provider. You need them to tell you why the call is not completing correctly.

Recently I was helping a customer set up a trunk to didlogic. His Asterisk server was sending the call to didlogic, but their system was responding with a fairly generic reply, indicating the SIP credentials were incorrect.

They seemed either unable or unwilling to investigate why this was. Even after being provided with SIP traces they showed no interest, just replying with generic suggestions that were no help.

It turned out that creating a new SIP account in the didlogic web portal resolved the issue. The old SIP credentials didn’t work, the new SIP credentials did.

I get asked a lot for call provider recommendations, and this is the only experience I have with didlogic, but based on it I couldn’t recommend them.

If you are having issues sending SIP calls to them (and getting just s SIP 407 back) maybe try creating a new set of SIP credentials in the didlogic portal.

Update 30/5/2014

I had a response to this post from DIDLOGIC which sounds encouraging. This was the reply –

Hello Matt,
Thanks very much for taking the time to detail these issues. It has been a couple of months and we have made our maximum effort to get a handle on the situation with authentication errors related to various flavors of Asterisk.
We apologize for causing your such inconvenience. Please be advised that there is now much more scope for troubleshooting these rare occurrences, as we have invested heavily in improving our support and customer service.

In case you ever run into such difficulty again, please send a short message to [email protected] and CC the engineer assigned to your account. All system builders and VoIP consultants integrating our SIP trunking solutions for their clients get a dedicated point of contact and such trivial issues are dealt with immediately.

Thanks again for trying our services.

OpenVPN to Asterisk using a Microtik router

Microtik RB750GL

Microtik RB750GL

For a while now SysAdminMan has been offering FreePBX/A2Billing hosting with OpenVPN server already installed on the server. What I really want to find is the perfect client/router that’s simple to configure and easy to deploy. We’ve been recommending OpenWRT for a while now but it can be a pain to flash the firmware and get OpenVPN configured.

I’ve also used Microtik routers for a while and they are very powerful routers in such a small, reasonably priced, package. This test was done using a Microtik RB750GL

I wasn’t sure how it would work though as Microtik routers only support OpenVPN over TCP, not UDP. This means all the VOIP traffic will be running over a TCP connection which, in theory, is not ideal.

This performance testing was done using –

  • Virgin Media Broadband with 60mb down and 3mb up. The upload limit on your broadband connection will nearly always be the limiting factor for call quantity/quality
  • Asterisk is running on a SysAdminMan VPS and is placing the incoming calls to music-on-hold
  • sipp was used  at the remote site to generate test calls
  • Linksys SPA941 was used at the remote site to test call quality
  • G711/aLaw was used for all calls
  • No other traffic was happening on the broadband connection

We start off with 10 concurrent calls, then 20 and finally 40.

10 CONCURRENT CALLS

Here you see we have sipp generating 9 G711 calls with audio

sipp 9 calls

sipp 9 calls

Continue reading

Phone won’t register with Asterisk 11.5.x – NAT issue

I had a customer today that was struggling to get a phone to register on a server with Asterisk 11.5.1 installed, even though it would register OK on a server with Asterisk 11.3

The phone was behind a NAT firewall, with the Asterisk server on a public IP address.

Looking at the SIP packets they were coming from port 50758 –

--- SIP read from UDP:XX.XX.XX.XX:50758 ---

but when Asterisk replied it was sending the reply to port 5062 –

--- Transmitting (no NAT) to XX.XX.XX.XX:5062 ---

Now with either –

nat=yes

or –

nat=force_rport,comedia

on the extension Asterisk should have been replying to the port the traffic came from, but it wasn’t. Looks like this is caused by a currently unresolved bug in Asterisk – https://issues.asterisk.org/jira/browse/ASTERISK-22236

Something to check if you are having difficulty registering an extension. This will not affect all extensions as if a SIP ALG was changing to port in the SIP headers then Asterisk would be replying to the correct port.

Improving Asterisk call quality with SIP jitter buffers

I had a customer let me know that they had improved their call quality from WiFi and 3G connections by turning on the Asterisk jitter buffers for SIP connections. If you have any extensions where connection quality is intermittent it could be worth trying.

This can by done with the FreePBX SIP Settings module or by adding the following lines to –

/etc/asterisk/sip_general_custom.conf

jbenable=yes
jbimpl=adaptive

 

After changing you should restart Asterisk or ‘sip reload’ from the console.

If you are just using Asterisk the change would go in the [general] section of sip.conf

If you try this option and notice any difference to call quality please post a comment below. Thanks!