Re: [Asterisk-java-users] Little help with the Command Action
Brought to you by:
srt
|
From: Stefan R. <sr...@re...> - 2005-10-21 06:29:47
|
Hi,
what version of Asterisk do you use?
=3DStefan
On Fri, 2005-10-21 at 14:07 +1000, Samant Nagpaul wrote:
> Hello,
> =20
> I am getting an error when I try sending a CLI command through the
> command action.=20
> =20
> Has anybody experienced this before? If I run any other action it
> works except CommandAction.
> =20
> =20
> 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)
> =20
> This is the code I am using
>=20
> public class CManager implements ManagerEventHandler,
> ManagerResponseHandler
> {
> private ManagerConnection managerConnection;
> =20
> public static void main(String[] args) throws Exception
> {
> CManager recordingManager;
> =20
> 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");
> }
> =20
> 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);
> =20
> ManagerResponse originateResponse;
> =20
> CommandAction commandAction =3D new CommandAction();
> commandAction.setCommand("show voicemail users");
> =20
> managerConnection.login();
> System.out.println("Logged in");
> =20
> originateResponse =3D
> this.managerConnection.sendAction(commandAction);
> =20
> String response =3D originateResponse.getResponse(); =20
> =20
> managerConnection.logoff();
> System.out.println("Logged out");
> System.out.println(response);
> return response;
> }
> =20
>=20
> 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
> }
>=20
|