System information
This sample configuration is set up to only allow local connections to
the AMI. If you intend on making this interface available over a network,
it is strongly recommended that you only do so using TLS. The use of
TLS is discussed in more detail later in this chapter.
Once the AMI configuration is ready, enable the built-in HTTP server by putting the
following contents in /etc/asterisk/http.conf:
;
; Enable the built-in HTTP server, and only listen for connections on localhost.
;
[general]
enabled = yes
bindaddr = 127.0.0.1
AMI over TCP
There are multiple ways to connect to the AMI, but a TCP socket is the most common.
We will use telnet to demonstrate AMI connectivity. This example shows these steps:
1. Connect to the AMI over a TCP socket on port 5038.
2. Log in using the Login action.
3. Execute the Ping action.
4. Log off using the Logoff action.
Here’s how the AMI responds to those actions:
$ telnet localhost 5038
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Asterisk Call Manager/1.1
Action: Login
Username: hello
Secret: world
Response: Success
Message: Authentication accepted
Action: Ping
Response: Success
Ping: Pong
Timestamp: 1282739190.454046
Action: Logoff
Response: Goodbye
Message: Thanks for all the fish.
Connection closed by foreign host.
458 | Chapter 20: Asterisk Manager Interface (AMI)