VoIP, Asterisk, and Java Michael P. Plezbert Agilis Systems, Inc St. Louis Java Users Group April 13, 2006
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Overview VoIP Basics Asterisk PBX Asterisk Gateway Interface Manager Interface Asterisk-Java Library Example Security Resources About Us
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 VoIP Two-way (pseudo-) real-time audio communication over IP network Allows “free” computer-to- computer calls (disregarding broadband connection fees), e.g. Skype Calls to “regular” phone network requires specialized hardware or service provider, e.g. Vonage
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 VoIP Pros Allows use of single network for voice and data Cost savings over traditional PBX Can leverage IT support staff Easier interaction with computer/data systems Cons Reliability of data network becomes paramount Latency and jitter are problems, requiring overallocation of bandwidth and/or QoS Requires VoIP phones or other specialized hardware to emulate traditional phone experience
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Asterisk PBX Open source software PBX system Runs on commodity computer hardware (x86) and software (linux/BSD) Supports standard VoIP protocols Hardware available for connection to POTS network Many features built in, e.g. voic , call queues, conference calls
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Asterisk Interaction Asterisk can communicate with external programs in several ways Call a local script More suitable for scripting languages than Java Connect via socket to an “AGI server” Simple text messages back and forth Server can be written in any language that supports socket comm Cannot be used to originate calls Accept socket (telnet) connections to a manager interface Can be used to originate calls and receive other events Read local “call files” Simple way to originate calls
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Asterisk Gateway Interface 1: a call comes into the asterisk server 2: the asterisk server makes a socket connection to an AGI server 3: the AGI server sends commands and receives results over the socket, controlling the flow of the call Note that the AGI server cannot originate a call using this interface
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 AGI Commands The AGI contains many commands for controlling a call, including answer hangup stream file Limited to streaming local sound files on the asterisk server, NOT over the socket interface wait for digit record file Records to local file on the asterisk server
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Manager Interface 1: client connects via socket to the asterisk manager interface and initiates a call 2: asterisk server places the call 3: when call connects, asterisk server connects via socket to the AGI server 4: the AGI server can send commands and receive results and events over both the AGI socket connection and the manager interface connection
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 The Asterisk-Java Library Implements both the AGI server interface and the manager client interface Contains classes and methods for sending commands and receiving events Eliminates the need to manually build or parse command strings
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 An Example Simple example will Originate a call Play a sound file Wait up to 5 seconds for a response If 1, 2, or 3 is pressed then Play sound files indicating digit pressed Else Play sound file indicating invalid choice Hangup
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Security VPN or ssl-tunnel suggested Socket comm is plain text (including authentication to manager interface) AGI connection is not authenticated Asterisk configuration Limit accessibility of external calls
VoIP, Asterisk, and Java St. Louis JUGApril 13, 2006 Resources Asterisk: Asterisk-Java Library: