Unable to connect to Asterisk Manager from /var/lib/asterisk/bin/retrieve_conf

So I followed about 3 or 4 methods of installing Asterisk 2.9/2.10 and Asterisk 1.8 on CentOS 5 on a VPS, using all default values and passwords (yes, I tried custom passwords also and I’ll change them later once I figure out were the problem is) I got it to install. So the first time I log into the web interface I have to click the “Apply Changes” button, but once I do that it gives be this error:

exit: 1
Sun, 04 Nov 2012 08:27:17 +0400 - Unable to connect to manager localhost:5038 (4):
[FATAL] Unable to connect to Asterisk Manager from /var/lib/asterisk/bin/retrieve_conf, aborting

1 error(s) occurred, you should view the notification log on the dashboard or main screen to check for more details.

So I’ve gone through all of the postings I could find, tried every suggestion that was suggested, changing bind address, changing ownership… etc. I’ve made sure amportel.conf and manager.conf match-up, and I tried executing retrieve_conf as root. The result of which is below:

[[email protected] ~]# /var/lib/asterisk/bin/retrieve_conf
Sun, 04 Nov 2012 08:54:35 +0400 - Unable to connect to manager localhost:5038 (111): Connection refused
[FATAL] Unable to connect to Asterisk Manager from /var/lib/asterisk/bin/retrieve_conf, aborting

What could be the problem, what am I missing, I know its most likely something very simple, but I’m stumped, I’ve spent about 40 hours now figuring this out and no luck. Any suggestions?

Well I guess you missed the warnings at the top of the file not to modify amportal.conf.

You can’t use pre 2.9 docs, you must set in advanced settings module from FreePBX GUI.

The only setting you need to make to a file is freepbx.conf with your DB credentials.

So I reinstalled, like a 6 or 7th time, again, with 2.10. I did not change any of the freepbx.conf, amportel.conf, or manager.conf files, just made sure they match, and they do, but I still get the same error:

Reload failed because retrieve_conf encountered an error: 1
exit: 1
[FATAL] Unable to connect to Asterisk Manager from /var/lib/asterisk/bin/retrieve_conf, aborting
1 error(s) occurred, you should view the notification log on the dashboard or main screen to check for more details.

so I tried executing retrieve_conf as root and I get a different result this time:

[[email protected] ~]# /var/lib/asterisk/bin/retrieve_conf
Added to globals: ASTETCDIR = /etc/asterisk
Added to globals: ASTMODDIR = /usr/lib/asterisk/modules
Added to globals: ASTVARLIBDIR = /var/lib/asterisk
Added to globals: ASTAGIDIR = /var/lib/asterisk/agi-bin
Added to globals: ASTSPOOLDIR = /var/spool/asterisk
Added to globals: ASTRUNDIR = /var/run/asterisk
Added to globals: ASTLOGDIR = /var/log/asterisk
Added to globals: CWINUSEBUSY = true
Added to globals: AMPMGRUSER = admin
Added to globals: AMPMGRPASS = amp111
Added to globals: AMPDBENGINE = mysql
Added to globals: AMPDBHOST = localhost
Added to globals: AMPDBNAME = asterisk
Added to globals: AMPDBUSER = asteriskuser
Added to globals: AMPDBPASS = amp109
Added to globals: VMX_CONTEXT = from-internal
Added to globals: VMX_PRI = 1
Added to globals: VMX_TIMEDEST_CONTEXT =
Added to globals: VMX_TIMEDEST_EXT = dovm
Added to globals: VMX_TIMEDEST_PRI = 1
Added to globals: VMX_LOOPDEST_CONTEXT =
Added to globals: VMX_LOOPDEST_EXT = dovm
Added to globals: VMX_LOOPDEST_PRI = 1
Added to globals: MIXMON_DIR =
Added to globals: MIXMON_POST =
Please update your modules and reload Asterisk by browsing to your server.

So I still don’t get it. everything is default and I didn’t change anything, and it still doesn’t work.

How are you reinstalling? Are you still using Asterisk Now? Have you considered trying the official distro?

I am using asterisk 1.8, If I had the possibility, to load my VPS from an ISO I would, but my VPS provider is not giving be that option, so for now I’m using CentOS-5-x86_64, that seems to work best during installation.

Ok, so you are downloading the tarball from this site, untaring it and running install_amp script?

Yes, I’m using install_amp. Pretty much I’m running the following script:

yum -y remove .i?86
yum -y groupremove 'DNS Name Server’
yum -y groupremove 'Editors’
yum -y groupremove 'Legacy Network Server’
yum -y groupremove 'Mail Server’
yum -y groupremove 'Network Servers’
yum -y groupremove 'System Tools’
yum -y groupremove 'Text-based Internet’
yum -y groupremove 'Web Server’
yum -y groupremove 'Windows File Server’
echo "exclude=
.i?86" >> /etc/yum.conf
yum -y update
yum -y groupinstall core
yum -y groupinstall base
yum -y install gcc gcc-c++ wget bison mysql-devel mysql-server php php-mysql php-pear php-pear-DB php-mbstring nano tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel php-gd audiofile-devel gtk2-devel subversion
yum -y remove yum-updatesd cups cups-lpd redhat-lsb autofs pcsc-lite smartmontools cpuspeed
chkconfig iscsi off
chkconfig iscsid off
service iscsid stop
service iscsi stop
yum -y install rsyslog
chkconfig syslog off
chkconfig rsyslog on
service syslog stop
service rsyslog start
echo “/bin/rm -rf /dev/null” >> /etc/rc.local
echo “/bin/rm -rf /dev/random” >> /etc/rc.local
echo “/bin/rm -rf /dev/tty*” >> /etc/rc.local
echo “/bin/rm -rf /dev/pty*” >> /etc/rc.local
echo “/bin/mknod -m 0666 /dev/null c 1 3” >> /etc/rc.local
echo “/bin/mknod -m 0644 /dev/random c 1 8” >> /etc/rc.local
echo “/sbin/MAKEDEV tty” >> /etc/rc.local
echo “/sbin/MAKEDEV pty” >> /etc/rc.local
rm -f /etc/selinux/config
echo “# This file controls the state of SELinux on the system.” >> /etc/selinux/config
echo “# SELINUX= can take one of these three values:” >> /etc/selinux/config
echo “# enforcing - SELinux security policy is enforced.” >> /etc/selinux/config
echo “# permissive - SELinux prints warnings instead of enforcing.” >> /etc/selinux/config
echo “# disabled - SELinux is fully disabled.” >> /etc/selinux/config
echo “SELINUX=disabled” >> /etc/selinux/config
echo “# SELINUXTYPE= type of policy in use. Possible values are:” >> /etc/selinux/config
echo “# targeted - Only targeted network daemons are protected.” >> /etc/selinux/config
echo “# strict - Full SELinux protection.” >> /etc/selinux/config
echo “SELINUXTYPE=targeted” >> /etc/selinux/config
echo “# SETLOCALDEFS= Check local definition changes” >> /etc/selinux/config
echo “SETLOCALDEFS=0” >> /etc/selinux/config
setenforce 0se
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
cd /usr/src
wget http://mirror.freepbx.org/freepbx-2.10.0.tar.gz
tar zxvf freepbx-2.10.0.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz
tar zxvf asterisk-1.8-current.tar.gz
cd /usr/src/asterisk-1.8*
make clean
./configure && make menuselect
#####################################################
./contrib/scripts/get_mp3_source.sh
make && make install && make samples
useradd -c “Asterisk PBX” -d /var/lib/asterisk asterisk
mkdir /var/run/asterisk
chown -R asterisk:asterisk /var/run/asterisk
chown -R asterisk:asterisk /var/log/asterisk
chown -R asterisk:asterisk /var/lib/asterisk/moh
chown -R asterisk:asterisk /var/lib/php/session
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
cd /usr/src
wget http://sourceforge.net/projects/mpg123/files/mpg123/1.13.4/mpg123-1.13.4.tar.bz2/download
tar -xjvf mpg123-1.13.4.tar.bz2
cd mpg123-1.13.4
./configure && make && make install
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
sed -i “s/User apache/User asterisk/” /etc/httpd/conf/httpd.conf
sed -i “s/Group apache/Group asterisk/” /etc/httpd/conf/httpd.conf
sed -i “s/AllowOverride None/AllowOverride All/” /etc/httpd/conf/httpd.conf
service mysqld start
cd /usr/src/freepbx-2.10.0
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql
###########################################
#GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO [email protected] IDENTIFIED BY ‘amp109’;
#GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY ‘amp109’;
#flush privileges;
#\q
#############################################
mysqladmin -u root password 'amp109’
sed -i “s/TTY=9/#TTY=9/” /usr/sbin/safe_asterisk
service httpd restart
/usr/sbin/safe_asterisk
cd /usr/src/freepbx-2.10.0
./install_amp
##defaults
rm -f /etc/asterisk/sip_notify.conf
rm -f /etc/asterisk/iax.conf
rm -f /etc/asterisk/logger.conf
rm -f /etc/asterisk/features.conf
rm -f /etc/asterisk/sip.conf
rm -f /etc/asterisk/extensions.conf
rm -f /etc/asterisk/ccss.conf
rm -f /etc/asterisk/chan_dahdi.conf
sed -i “s/;hostname/loguniqueid=yes\r\n;hostname/” /etc/asterisk/cdr_mysql.conf
echo /usr/local/sbin/amportal start >> /etc/rc.local
chkconfig httpd on
chkconfig mysqld on
reboot

I have tried installing this to two different machines from the standard ISO.
Version Stable-1.1009.210.62
1st machine was a Pentium 4 2.8 GHz Machine with 2 Gigs RAM
2nd machine is a AMD Athlon System with 1 Gig.

I am not modifying any files whatsoever.

OK well something with the virtual server is not letting the asterisk user execute commands and it seems to not be a linux level thing as best as I can see but something with how the virtual server is working.

To test run the following command as root and it works fine
/var/lib/asterisk/bin/retrieve_conf

Now run the same command as the asterisk user and it fails
sudo -u asterisk /var/lib/asterisk/bin/retrieve_conf

Not sure where to go from here as its not a FreePBX issue or install issue but something with the user permissions. Any ideas?

Maybe you should try:-

amportal chown

tried that, changed permisions, changed owners, changed groups, tried changing everything I could come up with, still doesnt want to run under asterisk user

paste:-

ls -l /var/lib/asterisk/bin/retrieve_conf

cat /etc/passwd|grep asterisk

grep -r asterisk /etc/httpd/conf/*

and

cat /etc/sudoers|grep asterisk

when i run: ls -l /var/lib/asterisk/bin/retrieve_conf
gives me this:
-rwxrwxrwx 1 asterisk asterisk 34974 Nov 8 13:19 /var/lib/asterisk/bin/retrieve_conf

but when i run: sudo -u asterisk /var/lib/asterisk/bin/retrieve_conf
Still gives me this error:
[FATAL] Unable to connect to Asterisk Manager from /var/lib/asterisk/bin/retrieve_conf, aborting

Any chance you have selinux running?

This is the selinux config file, should be disabled:

cat /etc/selinux/config

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - SELinux is fully disabled.

SELINUX=disabled

SELINUXTYPE= type of policy in use. Possible values are:

targeted - Only targeted network daemons are protected.

strict - Full SELinux protection.

SELINUXTYPE=targeted

SETLOCALDEFS= Check local definition changes

SETLOCALDEFS=0

near the top of retrieve.conf is :-

//include bootstrapper
$bootstrap_settings[‘freepbx_auth’] = false;
if (!@include_once(getenv(‘FREEPBX_CONF’) ? getenv(‘FREEPBX_CONF’) : ‘/etc/freepbx.conf’)) {
include_once(’/etc/asterisk/freepbx.conf’);
}

if (!$bootstrap_settings[‘astman_connected’]) {
fatal(sprintf(_(“Unable to connect to Asterisk Manager from %s, aborting”),FILE));
}

Your freepbx.conf file does not contain a suitable user/password that agrees with your/etc/asterisk/manager* heirarchy and/or depending on the version of FreePBX you are using in your mysql tables

so how would i check that my mysql tables have the same user/password as the /etc/asterisk/manager* heirarchy and the freepbx.conf file?

Just wondering what the solution was on your problem.

Me too… I hate it when threads are left open and unfinished…

Hey guys. Here’s a simple solution to change these settings in mysql.

Simply type:
amportal a m
then
UPDATE freepbx_settings SET value=‘newpassword’ WHERE keyword=‘AMPMGRPASS’;