Monday, June 22, 2009

Nokia E71 - Suddenly can't register to FreePBX

So, everything was good. I was frolicking in a green, grassy field on a spring day doing little turny-dance moves with my Nokia E71 - because it was working perfectly with our home-brew FreePBX system. But then it stopped. Suddenly. Everything went dark and gloomy.

Here's what happened:

I registered just fine like usual on my home WIFI network.
I made a call to an extension using X-lite somewhere out in WAN-land
The call connected and the first few seconds were good. Then the call got choppy and disconnected. I was able to call back, but on the second call it dropped and from that point forward I was no longer able to register with our PBX.

To troubleshoot the issue, here is what I did:

1. Attempted simple web connection on E71 - success
2. Attempted to register to our PBX by using Fring's quick and easy SIP subscription and entering my extension information - success! <-- that one surprised me
3. Connect to extension and do a successful call using X-lite on a totally separate machine but in the same LAN. - success

So, I concluded that the router and home internet connection is not the problem (step #1 above) and that the PBX is not the problem (because Fring could connect). I also figured out that all the specific extension settings were ok by step #3. These are good steps to log for quick troubleshooting.

So the problem, then, MUST be related to my Nokia's built in SIP settings OR the actual WIFI connection.

I should note that my E71 was setup as a static IP in my router as well as in the Nokia's WIFI connection advanced settings (ask us if you don't know how to find those because they're really well hidden!)

As a first step, I completely erased all SIP setting profiles in my Nokia. I figured that I must have messed around with something and screwed them up. I re-entered them again the way that I knew they used to work according to this GREAT tutorial (http://www.geek.com/articles/mobile/feature-voip-with-nokia-e71-how-to-2008095/). - FAIL!

After much messing around with my router and DMZ, etc, and still not being able to do it, I decided to do something Disposable Joe once showed me in a coffee shop - completely erase the WIFI connection from the WLAN list. I just nuked it. Then, I re-scanned for available networks and re-added my WIFI connection. Of course, the default connection is dynamic (not static) but what was interesting was that my Nokia immediately registered to our PBX!

I did a test call and it was ok if I called out to another extension, but not if a call came in (they couldn't hear my voice). THankfully, I"m pretty sure this is just a port problem and once I set it up as static IP in my router again, it should work. Let's try!

Test 1a: E71 @ home > DJ @ Work = No problem.
Test 1b: DJ @ work > E71 @ home = just got my voicemail

Test 2a: E71 @ home > mom @ home = no problem
Test 2b: mom @ home > E71 @ home = she just got my voice mail

Confirmed problem is on my side, my router, my ports. Next test is to turn my phone back to a static IP to see if that magically fixes everything.

Step one, change E71's WIFI advanced settings to static and give it a unique IP tag
You'll need:
-to choose a unique static ip (I chose .107)
-to have your router's default IP address (dlinks are 192.168.0.1)
-to find your primary/secondary dns settings (found in your router somewhere)(in Dlinks under the 'status' tab)

Step two: set up your phone in your router as a Static IP device. I did this in my dlink under the DHCP button on the 'home' tab

Instant FAIL! Grrr

Ah HA! The classic problem (and all E71 users, please note)

In your SIP settings of your nokia, make sure it's 'always on' and not 'when needed'. I have no idea why, but this has caused us much headache before. Just memorize that it should be 'always on' and not the other. The other seems to be the default so if you wipe a profile/start a new one, I think it defaults to the one that doesn't work. As soon as I changed to 'always on' boom. It registered. Now to test as per above:

Test 1a: E71 @ home > DJ @ Work = success
Test 1b: DJ @ work > E71 @ home = fail!

Test 2a: E71 @ home > mom @ home = success!
Test 2b: mom @ home > E71 @ home = success!

So now I'm very confused. It seems to work with my mom but not DJ....

Hopefully I'll be able to follow up with some good news.

Thursday, June 18, 2009

"You have no right to access..."

So far, every sound file that we have uploaded (IVR or moh) has been assigned the user:group of apache:apache. I did some snooping around, and I read something about httpd.conf.

So, I opened up /etc/httpd/conf/httpd.conf and found the following:


# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# . On SCO (ODT 3) use "User nouser" and "Group nogroup".
# . On HPUX you may not be able to use shared memory as nobody, and the
# suggested workaround is to create a user www and use that user.
# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
# when the value of (unsigned)Group is above 60000;
# don't use Group #-1 on these systems!
#
User apache
Group apache
I changed the

User apache
Group apache

to

User asterisk
Group asterisk

Then I did a reboot on the box. Now, when I uploaded the files they had the correct user:group! Yes! I'm not sure if there will be other consequences of changing the user:group in httpd.conf, but so far it is nice.

DJ@Paris

Moh-fo

Music on hold (moh) has been put on hold...

In FreePBX webgui you can upload a sound file for moh. It ask for a wav or an mp3, but apparently mp3s don't work out of the box on Trixbox. There is some kind of converter that is not installed by default, and so it doesn't work. We may update that some day, but for a quick solution, we'll use a wav file with the same properties as the IVR (8bit mono etc).

So, going through the webgui, I tried to upload the wav, and go the following error(s):

1. Orgingally it said that the upload limit size was 2M. So, I edited /etc/php.ini so that

max_upload_size = 10M instead of 2M.

2.
Error Processing: "sox: Can't open input file '/var/lib/asterisk/mohmp3/orig_studyno3.wav': No such file or directory" for studyno3.wav!
This is not a fatal error, your Music on Hold may still work.
...but probably not. For one thing the directory /var/lib/asterisk/mohmp3 didn't even exist, so I did:

mkdir /var/lib/asterisk/mohmp3

Then set the permission as before chown -R asterisk:asterisk /var/lib/asterisk/mohmp3

Then, we need to change the permissions on the folder so that the user:group (ie asterisk:asterisk) can read, write, and execute files (7) in mohmp3, and others can read and extecute (5):

chmod 775 /var/lib/asterisk/mohmp3

I uploaded the file again... success! Sort of:

Error Processing: "sox: Input and Output rates must be different to use resample effect" for studyno3.wav!
This is not a fatal error, your Music on Hold may still work.
Yes, it may, and probably does still work. That error can be more or less ignored. I think it basically is saying that my file was already in the same format to which it would have been converted... had the converter been installed.

Moh for your money.

DJ@Paris

EDIT:

As per MT's comment, the moh still didn't work. That is because all of the uploaded files seem to still have the apache:apache ownership. We must be uploading them incorrectly. I chown-ed them to asterisk:asterisk, so they should work now. I guess the IVR might need re-chown-ing everytime we upload as well.

DJ@Paris

Wednesday, June 17, 2009

File Permissions - Why? Why?

It seems that our installation of FreePBX has been plagued with file permission problems. Thankfully, Disposable Joe is slightly more nerdy than I and seems to know not only how to access these things but fix them. I aspire to be likd DJ one day...

So, as discussed in other posts, we had file permission problems with:
-our voicemail
-some extensions <--or was that something else..i recall a .conf file

Now we have what appears to be an issue with file permissions for our Music on Hold. I am trying to upload a PBX-ready file (see my post about doing that if you are interested) but it keeps flippin' up a blank page and not doing anything. Usually this is a file permission issue, I think. Let's see what DJ can do! Bloggit, DJ! How about we make a 12" remix name for you like "DJ PBX"

Tuesday, June 16, 2009

Why no mailbox? 2

Problem:

I can access the voicemail, but I can't record a voicemail greeting; it cuts off as soon as it beeps.

What's happening:

The permissions are probably wrong on the folder in which the greeting is trying to be written. In other words, asterisk does not have permissions to write to the folder. If you look in the Asterisk CLI when you try to record a message, you will see:
x=0 ...

When it works, you will see:
x=1 ... after.

Probably the voicemail conext is wrong... That's why no mailbox.

Solution:

Make sure that your VM Conext in the Trixbox webgui says "default" and your ext mailbox is extention@default. The default folder has set permissions that are supposed to work.

In /etc/asterisk/voicemail.conf

Put your extensions under [default].. ie:

[default]
1234 => 9999,Bob,,,attach=no|saycid=no|envelope=no|delete=no
1235 => 9999,Rob,,,attach=no|saycid=no|envelope=no|delete=no


DJ@Paris

Creating an IVR (voice menu) in FreePBX

Now that you have your professional recording created in Audacity (see my other post), now you need to make the backbone work so that when your sexy voice says 'press 1 to speak to sexy me' that it actually reaches you, not your mother.

I'm pretty sure (but don't quote me on this) that you MUST have a trunk and some inbound/outbound routes set up before doing the IVR. If I'm right, i save you many headaches. If I'm wrong you're no further behind. So just start this part near the end of your PBX (Princess Ballerina X-ray) project.

Go to your control panel and then click IVR. On the right click 'Add IVR'. Give it a name that you'll remember, like 'General Voice Menu'.

Go to the bottom of the IVR options and enter the numbers in the little boxes on the left that you want people to press. click the drop down to make sure that when they press that number that it goes to the right destinations. Of course you have to have extensions before you even start this process so if you haven't done this, put this post on hold and go and make some extensions.

Most importantly, make sure that your actual voice recording is linked under 'announcements'. So, click the drop down and choose your audio file that you already prepared to play for the callers as per my other post.

-save
-apply configuration changes
-continue with reload
(always do the above anytime you want your changes to be remembered. It's a good habit)

Now your IVR is set up. However, will it play your recording? And when? You have to think of the IVR as a 'pseudo-extension'. It must be the destination of a call, basically.

In our case (and probably the most common case) we want it to be the message/menu to appear when a regular phone caller (PSTN) calls in. So, they hear a message (the recording you made) and then get the menu. Here's how you do it:

go to 'inbound routes' on the left side of your control panel
click your DID (donkey incoming dad) number. It's your voip number and you must have already set it up before beginning this part, so, like above, if you don't have one and need one, go get yourself a DID number so PSTN callers can call you from their cell and landlines.

Got your number? Configured it? Disposable Joe may do a quick post on that but your DID number provider MUST be able to give you the configurations. If they can't change.

So, you've got your extensions set up.
You've got your trunk set up
You've got your inbound route set up
you've got your voice menu recorded and in the right format and uploaded to system recordings

So, you click the DID number that you have already set up (we're still in 'inbound routes' here, btw). Go down to the bottom and you should see, as long as you've set up your IVR as per above, this:

Set Destination
Terminate Call:
Extensions:
Voicemail:
IVR:

Put the radio dial to 'IVR' and then select the IVR you just created as per above

-submit
-save
-apply configuration changes
-continue with reload

MT@Vancouver

EDIT:
The IVR was techinically "working" , but when we called in, we could not hear the announcement message.

The reason was that the recordings in /var/lib/asterisk/sounds/custom/ or the directory "custom" did not have the right permissions (this is still a mystery).

I did an ls -l /var/lib/asterisk/sounds/custom to find the permissions set:

-rw-r----- 1 apache apache 441044 Jun 16 09:08 090525_current2.wav

Apache? Why apache? , anyway I changed the owership:group of the folder to asterisk and made it recursive:

chown -R asterisk:asterisk /var/lib/asterisk/sounds/custom

-rw-r----- 1 asterisk asterisk 441044 Jun 16 09:08 090525_current2.wav

Now the menu played when we called in...

DJ@Paris

Create Great-Sounding Recordings in FreePBX using Audacity

Hi DJ. This is MT. I'm glad to make my first Geek-Post on this useful blog. I bet at least one other geek will appreciate our notes.

After asking yourself the age-old question of "Why Mailbox" (see video) you must ask yourself "Why Audacity recordings?" The answer is simple: better quality control.

It is important to understand that using X-lite or another softphone or even IP phone hardware to record your messages, voice mails, announcements and other such recordings limits you not only to the maximum quality of your headset mic or phone, but also to one mono track. With a bit of extra work you can mix down multiple tracks and create very high quality recordings for your callers to hear when they call you. Also, it seems that FreePBX has some kind of built in way of supposedly controlling the volume of the recordings that the caller hears (ever heard a complaint that your messages were too loud or too quiet?) but we have found that whatever that control is, doesn't give us full control of volume. By using Audacity, you can adjust, in detail, every aspect of the audio file.

Before you begin, you'll need to take note of something important. This is where I wasted no less than probably 4 hours. If you go to the 'System Recordings' section of your control panel you'll be greeted by what looks like a helpful message:

Alternatively, upload a recording in any supported asterisk format. Note that if you're using .wav, (eg, recorded with Microsoft Recorder) the file must be PCM Encoded, 16 Bits, at 8000Hz:

So, I obviously just copied those settings in Audacity.

(Sidetrack): You'll need Audacity (open source audio software) to do this, so grab that here: http://audacity.sourceforge.net/ (/sidetrack)

So those settings above are missing something SUPER important. In fact, if you do not heed this, it simply won't work. It will seem like it's uploading. It might even seem like it uploaded, but your recording WILL fail. Here's the key. Your recording MUST BE MONO! So, once I figured that out (I had to deduce that, actually, by looking at the format requirements in the message!) I simply converted my Audacity project to mono from stereo and voila! It didn't work. Wha? Yeah. It still didn't work! So I wasted another two hours until I finally figured it out. Take SUPER special note of this gem. Not only does your Audacity project need to match the file requirements of the message, AND be a mono project, but it must also NOT CONTAIN ANY STEREO TRACKS! The problem I had is that a little music blip that I used was a stereo track and the file would not export correct to mono because of it. So, you must make sure that if you use any stereo tracks in your audio project that you make sure you manually set them to mono. Thankfully, it's really easy! You just go to your stereo track, click the little black arrow thing that points down and a menu appears where you can 'make mono track' (or something like that).

*090617 - correction: You must first click 'split stereo track' and then go back to the split tracks and do it again and click 'mono'.

Once you've made sure all your tracks are mono, and that your project is set to the correct format, you can export your project to one file which will become your message for your callers.

Before exporting, assure that your entire project is in the correct format. To do so, just go to 'edit/preferences/quality' and make sure it's like this (the last four I just kind of left as is):

-deafault sample rate: 8000Hz
-default sample format: 16bit
-real-time sample rate converter: fast-sinc interpolation <-- what is it?
-high-quality sample rate converter: high-quality sinc interpolation<-- what is it?
-real-time dither: none <-- what is it?
-high-quality dither: triangle <-- what is it?

Under the same window but under the 'file formats' tab, make sure the 'uncompressed export format' is set to 'WAV (Microsoft 16 bit PCM)'

You're ready to export!

To export, just go to 'file' and 'export as .wav'. To make sure your file is in the correct format, touch it with your mouse, right click, properties. In the 'general' tab you should see that it is a .wav file. In the summary tab, it MUST be like this:
-bit rate: 128kbs
-audio sample size: 16 bit
-channels: 1(mono)
-Audio sample rate: 8HZ
-Audio format: PCM

If it's not, go over this post again and adjust. Don't even try to use the file in your PBX box if it's not.

You've now determined that everything is good to go so now you need to get the audio file into your PBX. This is under 'system recordings' in your control panel. I would still recommend, at this point, just doing individual extension recordings using your hardware phone or softphone. Callers are used to this kind of quality and even expect it. I'm leery to even try a high quality extension recording unless the extension leads to a 'general department' and not an individual... but feel free to make a 12 inch remix techno recording for yourself. I think it's cool....

Anyways, if you can't figure out how to upload your recording to the system recordings, there's no hope for you anyways, so I won't bother explaining it.

Now that your recording is up there (let's assume it was an outgoing voice menu) now you need the actual voice menu so the thing works. that's called an IVR in PBX Land. You'll need to read my post called 'Setting up an IVR (Voice Menu) in FreePBX'

Until then. Stay geeky. Don't quit.

Why no mailbox?

For some reason, Trixbox doesn't come with a default voicemail context setup in the configuration file.

When I set up the extensions, the conext said "default" and the mailbox was "1234@".

I looked in the /etc/asterisk/voicemail.conf and it said
...
[default]

[]
[]
1234 => 9999,Bob,,,attach=no|saycid=no|envelope=no|delete=no
1235 => 9999,Rob,,,attach=no|saycid=no|envelope=no|delete=no

I don't know what those extra empty [ ] context were about so I deleted them and created my own:

[device]
1234 => 9999,Bob,,,attach=no|saycid=no|envelope=no|delete=no
1235 => 9999,Rob,,,attach=no|saycid=no|envelope=no|delete=no

So, then back in the Trixbox web gui, I changed the voicemail context to "device" and my mailbox "1234@device".

EDIT: Don't make your own context, and do not change the VM Context in the web gui (as per the warning!) Why? Because you can't record your VM greetings.

Keep it as:

[default]
1234 => 9999,Bob,,,attach=no|saycid=no|envelope=no|delete=no
1235 => 9999,Rob,,,attach=no|saycid=no|envelope=no|delete=no

And keep the VM Contest as "default" , the 1234@device shoud be 1234@default, so that you can access your mailbox on that context.

Success... sort of. I was able to connect to the voicemail box by dialing *97.

I entered the Asterisk CLI from the ssh with command: asterisk -r

I could see that I was entering the mailbox all right, but I could not hear anything...

After some research, I found out that it was a NAT issue.

Earlier in /etc/asterisk/sip_general_custom.conf I had added:

nat=yes
externip=72.32.23.235 <--- IP address of Internet connection
localhost=192.168.0.111 <-- local IP address of PBX box I left out a few things according to my research, so I changed it to read:
nat=yes
externip=72.32.23.235
externrefresh=300 <-- No idea what this is for
localhost=192.168.0.111/255.255.255.0 <-- local subnetmask I went into the asterisk CLI again and ran module reload to refresh the server and apply the conf changes.

I can now access my mailbox. Why? I don't know exactly.

DJ@Paris

Monday, June 15, 2009

X-istentialism

After adding extensions through the web gui, I was unable to register any devices. It seems that the nothing was making its way through the ports.

So, I added to /etc/asterisk/sip_general_custom.conf (called by sip.conf in Trixbox)

nat=yes
externip=72.32.23.235 <--- IP address of Internet connection
localhost=192.168.0.111 <-- local IP address of PBX box

I also did a reboot on the system. In any case, I was able to register after one or both of those things.

I used X-Lite as the SIP phone to test my extension.

X-Lite settings:

ACCOUNT tab

User Details
--------------
Display Name: Disposable Joe
User Name: 1234 <-- Extension created in the web gui
Password: ****** <-- The password (ie secret) for extension
Authorization Name: 1234 <--Enter the extension again
Domain: funpbxbox.dyndns.org <-- static dyndns.org address for the PBX

Domain Proxy
--------------
Check "Register with domain and receive incoming calls"

Send outbound via: domain <-- If you have a proxy, then use proxy, but we don't.

TOPOLOGY tab

Firewall Traversal
--------------
IP Address: Discover global address

STUN Server
--------------
Discover server
Uncheck "Enable ICE"

DJ@Paris

Portage

After a long and hard debate with our home routers, we found that the following port setup seemed to work best for us and our hardware.

PBX router (office) and home routers port forwarding to the static PBX IP address:

5000-5082 (TCP&UDP)*

8000-20000 (UDP)**

* This covers the standard Asterisk ports 5060 and 5061

** I edited our /etc/asterisk/rtp.conf so that

rtpstart=8000
rtpend=20000

I increased the range because someone told me to do that once. Maybe it helps.

DJ@Paris

Renaissance

Until now, we had a relatively perfectly working Asterisk PBX running on an old computer with Trixbox CE 2.6.2.2. I connected from Paris, while Mr. Taylor (MT) was in Vancouver, BC.

Suddenly the hard drive died and became read-only, and then eventually unreadable! After replacing the hard drive, we have installed Trixbox again, but it is in need of some re-configuring.

This time, we will log process and progress.

1. After installation, MT ran a system-config-network so that we could assign a static IP address to our PBX box from behind our router (D-LINK).

Static IP: 192.168.0.111 (example)
Subnet Mask: 255.255.255.0
Host: 192.168.0.1 (IP of the router)

For some reason the PBX was not reaching the network, and we found that some other devices were probably overlapping the static IP, so we gave the PBX a higher-numbered IP to avoid conflicts. This IP still shows up as something else on the DHCP table in the router settings even though the assigned static IP address 192.168.0.111 is accessible.

2. I ran a yum upgrade to upgrade the packages on the PBX.

3. By default the Web GUI is not accessible outside of the local network, so I will be using an ssh tunnel to reach the web gui for now, although THIS looks promising.

I also updated any modules via the web gui --> Module Admin --> Check for Updates.
I installed the IVR module for later (MT will take care of this).

4. We already had a dyndns.org static address set up for this. Forward your dyndns.org address to the IP address of your Internet connect for your PBX (ie. externip)

DJ@Paris