Re: [Asterisk-java-users] question about getting peers using SipShowPeerAction (AMI)
Brought to you by:
srt
From: Carlos G M. <tr...@hu...> - 2007-08-10 00:55:00
|
Hmm, your peer is "SIP/test1" or just "test1" ? Asterisk is not all that clean in naming things here and there. A bit of parsing here and there might help. I'm fighting right now with agents and all things that are taken for granted. Like Agent/XXXX being an agent callback channel, which is sometimes referred to by the context/extension used to reach it, sometimes by the channel being used by it... HTH Robert Prince @ 09/08/2007 21:38 -0300 dixit: > 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 > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > -- Carlos G Mendioroz <tr...@hu...> LW7 EQI Argentina |