Problems to handle a connection on AGI

Hi Guys!

We are trying to build a dialer with asterisk and asterisk-java libs. We can start a call to a extension, but it ends as soon it is answered.

Our asterisk server is at

Our java server is at

When monitoring, we see this log at rasterisk -vvvv

Connected to Asterisk certified/13.21-cert2 currently running on REALPBX (pid = 596)
== Manager ‘admin’ logged off from
== Connect attempt from ‘’ unable to authenticate
== Manager ‘admin’ logged on from
== Using SIP RTP CoS mark 5
– Called 1004
– SIP/1004-00000007 is ringing
[Aug 14 09:51:44] NOTICE[657]: chan_sip.c:28463 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 1004
> 0x7f68fc004840 – Strict RTP learning after remote address set to:
– SIP/1004-00000007 answered
– Executing [asterisk-java-agi@asteriskjava:1] AGI(“SIP/1004-00000007”, “agi://”) in new stack
[Aug 14 09:51:46] WARNING[848][C-00000007]: res_agi.c:2039 handle_connection: Connecting to ‘’ failed for url ‘agi://’: Connection refused
[Aug 14 09:51:46] WARNING[848][C-00000007]: res_agi.c:2104 launch_netscript: Couldn’t connect to any host. FastAGI failed.
– Auto fallthrough, channel ‘SIP/1004-00000007’ status is ‘UNKNOWN’

We are missing something, thanks for any help.

Our configuration file:

public class ExamplesAsteriskSettings extends DefaultAsteriskSettings{
public String getManagerPassword(){
// this password MUST match the password (secret=) in manager.conf
return “senha”;
public String getManagerUsername(){
// this MUST match the section header ‘[myconnection]’ in manager.conf
return “admin”;
public String getAsteriskIP(){
// The IP address or FQDN of your Asterisk server.
return “”;
public String getAgiHost(){
// The IP Address or FQDN of you asterisk-java application.
return “”;

Our code (nearly the same from documentation tutorial):

PBX pbx = PBXFactory.getActivePBX();
// We are going to dial from extension 100 to 5551234
// The trunk is used to select which SIP trunk to dial through.
Trunk trunk = pbx.buildTrunk(“tronco_ypy_movel”);
// We are going to dial from extension 100
EndPoint from = pbx.buildEndPoint(TechType.SIP, “1004”);
// Provide confirmation to the agent which no. we are dialing by
// showing it on their handset.
CallerID fromCallerID = pbx.buildCallerID(“5558100”, “Dialing”);
// The caller ID to display on the called parties phone.
// On most systems the caller id name part won’t display
CallerID toCallerID = pbx.buildCallerID(“5558101”, “Asterisk Java is calling”);
// The party we are going to call.
//EndPoint to = pbx.buildEndPoint(TechType.SIP, trunk, “1004”);
EndPoint to = pbx.buildEndPoint(TechType.SIP, trunk, “5558100”);
// Now dial. This method won’t return until the call is answered
// or the dial timeout is reached.
DialActivity dial = pbx.dial(from, fromCallerID, to, toCallerID);
// We should have a live call here. But we got null.
Call call = dial.getNewCall();

The exception made at pbx.dial(from, fromCallerID, to, toCallerID);

org.asteriskjava.pbx.PBXException: OperatorEndedCall

What do you not understand about this message?

Hi David!

I´m not sure, but I think this message means that asterisk server (res_agi.c at line 2039) is trying to respond or send a message to a resource (activityAgi).

I dont know if activityAgi is owned by Asterisk Java Application Server or by the Asterisk Server.

res_agi.c needs to connect with Asterisk (localhost or or with my Asterisk Java Application/Server (

WARNING[1509][C-0000000a]: res_agi.c:2039 handle_connection: Connecting to '' failed for url 'agi://': Connection refused

It is attempting to connect to port 4573 to talk to the AGI server. That would be your Asterisk Java Application Server, and it is unable to connect.

Thank you guys!

Problem solved. The asterisk-java server was not fully avaliable on my network.