[Asterisk-java-users] question about getting peers using SipShowPeerAction (AMI)
Brought to you by:
srt
From: Robert P. <ro...@ro...> - 2007-08-10 00:38:04
|
Hello asterisk-java folks, I've read the tutorial, and the javadoc, and browsed the mailing lists, but so far I can't find why what I'm trying to do does not work. I have an asterisk server (1.49), and two peers configured (called 'test1' and 'test2'). The peers connect and register properly and all that good stuff (using Linksys SPA2102). I'm trying to use asterisk-java to detect peer state changes - specifically, reachable and unreachable events. The following seems to be basic code for how to do that: ... (assume ManagerConnection works, we've logged in to the AMI successfully, etc) ... public void onManagerEvent(ManagerEvent event) { String peerName = ""; if (event instanceof PeerStatusEvent) { peerName = ((PeerStatusEvent) event).getPeer(); System.out.println("**** PeerStatusEvent: "+event); SipShowPeerAction showPeer = new SipShowPeerAction(peerName); managerConnection.sendAction(showPeer, new SendActionCallback() { public void onResponse(ManagerResponse response) { System.out.println("** Manager Response: " + response); } }); } if (event instanceof PeerEntryEvent) { System.out.println("** peer entry event - IP address: "+((PeerEntryEvent) event).getIpAddress()); System.out.println("** peer entry event - port: "+((PeerEntryEvent) event).getIpPort()); } What I hope this should do for me, if I'm reading the javadocs correctly, is poke the asterisk server into giving me (through asterisk-java) a PeerEntryEvent, so I can get the IP address and port. However, what I get is the following: **** PeerStatusEvent: org.asteriskjava.manager.event.PeerStatusEvent[dateReceived=Thu Aug 09 20:16:31 EDT 2007,privilege='system,all',timestamp='null',peer='SIP/test2',time='97',cause='null',peerstatus='Reachable',systemHashcode=22618484] ** Manager Response: org.asteriskjava.manager.response.ManagerError: actionId='null'; message='Peer SIP/test2 not found.'; response='Error'; uniqueId='null'; systemHashcode=10703525 **** PeerStatusEvent: org.asteriskjava.manager.event.PeerStatusEvent[dateReceived=Thu Aug 09 20:16:33 EDT 2007,privilege='system,all',timestamp='null',peer='SIP/test1',time='100',cause='null',peerstatus='Reachable',systemHashcode=8846886] ** Manager Response: org.asteriskjava.manager.response.ManagerError: actionId='null'; message='Peer SIP/test1 not found.'; response='Error'; uniqueId='null'; systemHashcode=9938272 I'm a bit confused ... I see the peer names in the PeerStatusEvents, but then the ManagerError says they don't exist. Is there something in manager.conf I need to do? I've configured it thus: [general] enabled = yes port = 5038 bindaddr = 0.0.0.0 [manager] secret=xxxxxxxx permit=0.0.0.0/0.0.0.0 read=all,event,system,call,log,verbose,agent,command,user write=all,event,system,call,log,verbose,agent,command,user Honestly I don't even know if 'all,event' are proper syntax or really do anything, but I have been trying lots of things to see if it's e.g. a configuration problem. Anyone have ideas? Much appreciated! Cheers, Robert |