[Asterisk-java-users] Little help with the Command Action
Brought to you by:
srt
|
From: Samant N. <sa...@ai...> - 2005-10-21 04:10:07
|
Hello,
I am getting an error when I try sending a CLI command through the =
command action.=20
Has anybody experienced this before? If I run any other action it works =
except CommandAction.
INFO: Connecting to 203.62.158.26 port 5038
# event : net.sf.asterisk.manager.event.ConnectEvent: dateReceived=3DFri =
Oct 21 14:05:33 EST 2005; systemHashcode=3D32019423
21/10/2005 14:05:33 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Connected via Asterisk Call Manager/1.0
21/10/2005 14:05:33 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Successfully logged in
Logged in
21/10/2005 14:05:33 net.sf.asterisk.util.impl.JavaLoggingLog error
SEVERE: Unable to retrieve internalActionId from response: asterisk sent =
actionId 'null':
net.sf.asterisk.manager.response.CommandResponse: actionId=3D'null'; =
message=3D'null'; response=3D'Follows'; uniqueId=3D'null'; =
systemHashcode=3D2917593
21/10/2005 14:05:33 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: responseHandler not found
21/10/2005 14:05:33 net.sf.asterisk.util.impl.JavaLoggingLog warn
WARNING: buffer contains neither response nor event
Exception in thread "main" net.sf.asterisk.manager.TimeoutException: =
Timeout waiting for response to Command
at =
net.sf.asterisk.manager.DefaultManagerConnection.sendAction(DefaultManage=
rConnection.java:421)
at =
net.sf.asterisk.manager.DefaultManagerConnection.sendAction(DefaultManage=
rConnection.java:397)
at CManager.runCommand(CManager.java:56)
at CManager.main(CManager.java:27)
This is the code I am using
public class CManager implements ManagerEventHandler, =
ManagerResponseHandler
{
private ManagerConnection managerConnection;
=20
public static void main(String[] args) throws Exception
{
CManager recordingManager;
recordingManager =3D new CManager();
recordingManager.runCommand("4003","samant123");
}
=20
public CManager() throws IOException
{
ManagerConnectionFactory factory =3D new =
ManagerConnectionFactory();
this.managerConnection =3D =
factory.getManagerConnection("locahost", "manager", "asterisk");
}
public CManager(String ip, String manager_username, String =
manager_password) throws IOException
{
ManagerConnectionFactory factory =3D new =
ManagerConnectionFactory();
this.managerConnection =3D factory.getManagerConnection(ip, =
manager_username, manager_password);
}
=20
public String runCommand(String channel, String fileName)=20
throws IOException, AuthenticationFailedException, TimeoutException
{
this.managerConnection.addEventHandler(this);
ManagerResponse originateResponse;
CommandAction commandAction =3D new CommandAction();
commandAction.setCommand("show voicemail users");
managerConnection.login();
System.out.println("Logged in");
originateResponse =3D =
this.managerConnection.sendAction(commandAction);
String response =3D originateResponse.getResponse(); =20
=20
managerConnection.logoff();
System.out.println("Logged out");
System.out.println(response);
return response;
}
public void handleEvent(ManagerEvent event)
{
System.out.println ("# event : " + event);
}
=20
public void handleResponse(ManagerResponse response)
{
System.out.println ("# response : " + response);
System.out.println ("# response : " + response.getAttributes());
}
=20
}
|