How to setup TNG for Asterisk using the AMI

TNG connects to Asterisk via the network to the Asterisk Manager Interface (AMI). The AMI normally runs on TCP port 5038 on the Asterisk machine.

Step 1: Enable the Asterisk Manager Interface
Step 2: Add a user for TNG
Step 3: Enable CDR on Asterisk
Step 4: Enable CDR via the AMI
Step 5: Force Asterisk to reload the configuration
Step 6: Configure TNG
Step 7: Check that TNG has connected successfully

Explanation of log entries

Steps:

  • Step 1: Enable the Asterisk Manager Interface

We first ensure that the AMI is enabled.

File /etc/asterisk/manager.conf

enabled = yes
port = 5038
bindaddr = 0.0.0.0

You should not enable the AMI on a public IP address.
If you do, people on the Internet will be able to connect to
the AMI and may cause problems.

Block this TCP port with iptables (or other firewall software).

  • Step 2: Add a user for TNG

The default Asterisk has a manager_custom.conf file, which
is included from /etc/asterisk/manager.conf. Usually, additional
users are configured in this file.

For example, if we want to use login “tng”, password “test”,
and TNG will connect from IP 192.168.0.4, this would be the
configuration:

File /etc/asterisk/manager_custom.conf

[tng]
secret=tng
deny=0.0.0.0/0.0.0.0
permit=192.168.0.4/255.255.255.255
read=system,command
write=system,command

Historically we used these settings, but it caused High CPU Usage.

read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user

You can make the login and password anything you want,
as long as TNG is configured to use the same login and password.

  • Step 3: Enable CDR on Asterisk

File /etc/asterisk/cdr.conf

[general]
enabled=yes
  • Step 4: Enable CDR via the AMI

We do not recommend using this anymore. Rather use the CSV file import facility.
File /etc/asterisk/cdr_manager.conf

[general]
enabled=yes
  • Step 5: Force Asterisk to reload the configuration

Check whether the cdr_manager module is loaded…

root@asterisk:/etc/asterisk# asterisk -rx "show modules like cdr_manager"
Module                         Description                              Use Count
cdr_manager.so                 Asterisk Call Manager CDR Backend        
01 modules loaded
root@asterisk:/etc/asterisk#`

Please see the Asterisk documentation if you have a problem with this part.
If the module is there, configure your TNG with the login and password
you set in Step 2.

Force Asterisk to reload the configuration:

asterisk -rx "reload"

if changes were made to the Config files you can reload the services.

asterisk -rx "reload manager"
asterisk -rx "reload cdr"
asterisk -rx "reload cdr_manager"

TNG should now be able to connect to Asterisk.

  • Step 6: Configure TNG

Make sure that TNG is installed.

Login on TNG using a web browser, and click on the
“General Settings” icon (a gear and spanner) on the
main page.

TNG will prompt for a “technical” password. Enter the
technical password and search on the screen for the
Asterisk Interface configuration.

Here you enter the IP address of the Asterisk server,
AMI port (default 5038), Login and password that you
configured in Step 2.

Click any of the “Apply Changes” buttons to save.

  • Step 7: Check that TNG has connected successfully

Back on Asterisk, at the command-line, check that TNG has connected:

asterisk -rx "show manager connected"  
Username         IP Address  
tng              192.168.0.5

If you don’t see this, check the TNG log file for
error messages.

  • Explanation of log entries

Look for these messages to check settings

Setting AMI Host :192.168.0.4
Setting AMI Port :5038                  
Setting AMI Login Name :tng     
  • Error message

AMI Exception:ConnectToAsterisk: Socket Error # 10061[13][10]Connection refused.

Explanation: Failed to connect to AMI
Reason: Incorrect IP or port, or a firewall

  • Error messages
AMI Exception:Disconnected.AMI
Exception:Send: Action: Login[13][10] Username: tng[13][10] Secret: test[13][10] - Socket Error # 10057[13][10]Socket is not connected.AMI connected to port 5038 on 192.168.0.4`

Explanation: Successful connect, connection was closed almost immediately
Reason: Incorrect login or password

SAMPLE FORMAT

"0000000000","0000000000","s" ,"all-hangup","Zap/1-1","SIP/5006-091feb88","Dial","SIP/5006|60","2007-11-09 11:24:32","2007-11-09 11:24:32","2007-11-09 11:24:35","3","3","ANSWERED","DOCUMENTATION","","1194600272.3176","2021"

Please find a detailed TNG installation and user’s guide in the help folder on your TNG CD.