Thread: [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 |
From: Stefan R. <ste...@re...> - 2007-08-10 00:52:48
Attachments:
signature.asc
|
Hi Robert, first thanks for your very well prepared question, it's a pleasure to reply to it :) > **** PeerStatusEvent: > org.asteriskjava.manager.event.PeerStatusEvent[dateReceived=3DThu Aug 0= 9 > 20:16:31 EDT 2007,privilege=3D'system,all',timestamp=3D'null',peer=3D'S= IP/test2',time=3D'97',cause=3D'null',peerstatus=3D'Reachable',systemHashc= ode=3D22618484] > ** Manager Response: org.asteriskjava.manager.response.ManagerError: > actionId=3D'null'; message=3D'Peer SIP/test2 not found.'; > response=3D'Error'; uniqueId=3D'null'; systemHashcode=3D10703525 The problem is that SipShowPeer requires only the name of the peer without the channel prefix ("SIP/"). Unfortunately the PeerStatus event returns the name with the channel prefix and Asterisk calls both attributes just "peer". I will have a look at the javadocs to make this more clear. For you this means you just have to strip the channel prefix before passing the peer name to the SipShowPeerAction. Hope that helps, Stefan --=20 reuter network consulting Neusser Str. 110 50760 Koeln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: ste...@re... Jabber: ste...@re... Steuernummern 215/5140/1791 USt-IdNr. DE220701760 |
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 |
From: Robert P. <ro...@ro...> - 2007-08-10 16:10:43
|
Hello Stefan, Thanks very much for your help - I'll give that a try! Cheers, Robert On 8/9/07, Stefan Reuter <ste...@re...> wrote: > Hi Robert, > > first thanks for your very well prepared question, it's a pleasure to > reply to it :) > > > **** 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 > > The problem is that SipShowPeer requires only the name of the peer > without the channel prefix ("SIP/"). Unfortunately the PeerStatus event > returns the name with the channel prefix and Asterisk calls both > attributes just "peer". I will have a look at the javadocs to make this > more clear. > For you this means you just have to strip the channel prefix before > passing the peer name to the SipShowPeerAction. > > Hope that helps, > > Stefan > > -- > reuter network consulting > Neusser Str. 110 > 50760 Koeln > Germany > Telefon: +49 221 1305699-0 > Telefax: +49 221 1305699-90 > E-Mail: ste...@re... > Jabber: ste...@re... > > Steuernummern 215/5140/1791 USt-IdNr. DE220701760 > > > ------------------------------------------------------------------------- > 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 > > > |
From: Robert P. <ro...@ro...> - 2007-08-11 00:25:09
|
Well ... I still haven't had much success. Here's the scenario that I'm using: First, all is set up as stated in the start of this thread. 1) I pull the plug on my ATA, causing my two peers (test1 and test2) to time out eventually. 2) I see the unreachable events in the Asterisk console: *CLI> [Aug 10 19:59:58] NOTICE[9540]: chan_sip.c:15360 sip_poke_noanswer: Peer 'test1' is now UNREACHABLE! Last qualify: 94 [Aug 10 20:00:05] NOTICE[9540]: chan_sip.c:15360 sip_poke_noanswer: Peer 'test2' is now UNREACHABLE! Last qualify: 93 3) I see the PeerStatusEvents from the code (forgive my **** and &&&&, it's to help me identify specific debugging statements): **** PeerStatusEvent: org.asteriskjava.manager.event.PeerStatusEvent[dateReceived=Fri Aug 10 20:09:46 EDT 2007,privilege='system,all',timestamp='null',peer='SIP/test2',time='-1',cause='null',peerstatus='Unreachable',systemHashcode=7359402] **** peer name: test2 &&&&&&&&& SipShowPeerAction action complete event class: class org.asteriskjava.manager.event.PeerlistCompleteEvent *** Manager Response: org.asteriskjava.manager.response.ManagerResponse: actionId='actionIdtest2'; message='null'; response='Success'; uniqueId='null'; systemHashcode=12577309 **** PeerStatusEvent: org.asteriskjava.manager.event.PeerStatusEvent[dateReceived=Fri Aug 10 20:09:47 EDT 2007,privilege='system,all',timestamp='null',peer='SIP/test1',time='-1',cause='null',peerstatus='Unreachable',systemHashcode=27475272] **** peer name: test1 &&&&&&&&& SipShowPeerAction action complete event class: class org.asteriskjava.manager.event.PeerlistCompleteEvent *** Manager Response: org.asteriskjava.manager.response.ManagerResponse: actionId='actionIdtest1'; message='null'; response='Success'; uniqueId='null'; systemHashcode=813251 But, I don't see PeerlistCompleteEvents, or PeerEntryEvents. What I expect from reading the javadoc is that when I send a SipShowPeerAction to the AMI, it should result in the AMI sending me back a PeerEntryEvent, and possibly also a PeerlistCompleteEvent (?not sure about that). But, I don't seem to get either. I've posted the (very simple) code I'm using on Google docs to see if it will help point out where I'm going wrong - please, feel free to take a look and if there's anything, let me know! http://docs.google.com/Doc?id=dcpvc479_33gqzn2s Cheers, Robert On 8/10/07, Robert Prince <ro...@ro...> wrote: > Hello Stefan, > > Thanks very much for your help - I'll give that a try! > > > Cheers, > > Robert > > On 8/9/07, Stefan Reuter <ste...@re...> wrote: > > Hi Robert, > > > > first thanks for your very well prepared question, it's a pleasure to > > reply to it :) > > > > > **** 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 > > > > The problem is that SipShowPeer requires only the name of the peer > > without the channel prefix ("SIP/"). Unfortunately the PeerStatus event > > returns the name with the channel prefix and Asterisk calls both > > attributes just "peer". I will have a look at the javadocs to make this > > more clear. > > For you this means you just have to strip the channel prefix before > > passing the peer name to the SipShowPeerAction. > > > > Hope that helps, > > > > Stefan > > > > -- > > reuter network consulting > > Neusser Str. 110 > > 50760 Koeln > > Germany > > Telefon: +49 221 1305699-0 > > Telefax: +49 221 1305699-90 > > E-Mail: ste...@re... > > Jabber: ste...@re... > > > > Steuernummern 215/5140/1791 USt-IdNr. DE220701760 > > > > > > ------------------------------------------------------------------------- > > 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 > > > > > > > |