Asterisk, AGI, and The Dreaded 510 Invalid or unknown command

Lately, I have been upgrading some Asterisk boxes for one of our clients, PhoneBurner.com. And I ran across this error and spent plenty of time Googling for it, without resolution. Here’s hoping that it helps someone else that’s in my shoes.

There were actually a few things happening here. When I initially upgraded Asterisk, everything was fine. However, I immediately upgraded PHP as well, which runs the AGI scripts. I was then pulled in other directions for a week or two, so things got a little muddled in the old memory banks.

Once I got back to work on it, I had forgotten that I tested prior to upgrading PHP. I then noticed these “510 Invalid or unknown command” error messages. After hours of searching, I called it a night, hoping to be refreshed in the morning.

I brought the issue up to someone else who happened across a blog post that only helped me accidentally. Their solution was to turn off debugging… but it got me thinking… Wait, maybe I should turn debugging on.

I did just that, and finally found the culprit. While upgrading PHP, I had turned debugging on in the database access layer and forgot to turn that off. It was writing out to STOUT, which was directly interacting with the AGI.

Bottom line… Don’t hide your errors. Don’t ignore them either. There could be output from your AGI Script that you are not aware of which is causing them. Find that, fix it, and you’ll be good to go.

I enjoy getting back into other areas of DevOps. While I love coding in PHP, it’s also nice to change things up and do things a little differently.