Thread: [Asterisk-java-users] NewChannelEvent and GetVarAction
Brought to you by:
srt
From: Robert S. <rls...@op...> - 2007-03-15 10:31:38
|
I'm using=20 asteriskjava 3 m1 asterisk 1.2.5 java 1.5.0_06-b05 My code dials out, and allows the user to cancel the call before it is = answered. To do this I've added a channel variable to the originate so = that I can identify the correct NewChannelEvent and and use the channel = name to hangup up before it's answered. The problem is this: When I receive the NewChannelEvent and request my = channel variable, sometimes I get an error back "No such channel". Am I doing something wrong?=20 I do know that if I add a 500ms delay as in the event handler below the = problem goes away. I could also repeat the request for the variable several times. It occurs to me that it could be asterisk-java doing something funny or = asterisk. I ran ngrep on the manager port and it seems to me that asterisk-java = isn't doing anything wrong. The ngrep trace is below as well, one with out the delay and one with = the delay. Does anyone have a better solution to this problem. Thanks in advance for your help. Robert ........ a cut down snippet that makes the call OriginateAction originate =3D new OriginateAction(); HashMap<String, String> myVars =3D new HashMap<String, String>(1); ManagerResponse response =3D null; myVars.put(TRC_CALL_ID, actionID); originate.setVariables(myVars); originate.setChannel(pChannel); originate.setContext(config.getSetting(Config.CONTEXT)); originate.setExten(config.getMeetMeExtension()); originate.setAsync(true); originate.setPriority(1); try { response =3D managerFactory.sendAction(originate, 30000); wait(); } catch (Exception e) { logger.error(e, e); } ........ this is my event handler if (event instanceof NewChannelEvent) { NewChannelEvent newState =3D (NewChannelEvent) event; String channel =3D newState.getChannel(); GetVarAction var =3D new GetVarAction(); var.setChannel(channel); var.setVariable(TRC_CALL_ID); try { /* * wait 500ms to allow asterisk time to make the channel variables * available. If you request the channel variables too soon asterisk * responds with channel not found. */ wait(500); ManagerResponse response =3D managerFactory.sendAction(var, 500); String callID =3D response.getAttribute("value"); if (callID !=3D null && callID.compareToIgnoreCase(actionID) =3D=3D = 0) { newChannelName =3D channel; logger.info("new channel name " + channel); } } catch (Exception e) { // TODO Auto-generated catch block logger.error(e, e); } } NGREP OUTPUT: what follows is a failure to retreive the channel variable *************************************************************************= *********************** T +0.064170 192.168.0.103:2081 -> 192.168.0.110:5038 [AP] action: Originate..actionid: 32260544_11#3..timeout: 30000..exten: = 303..async: true..variable: room=3D3750..variable: trcCallID=3D3..variable: = options=3DqdxA..context: trc..priority: 1..channel: I AX2/09508696@faktortel/94044931.... # T +0.003224 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Response: Success.. # T +0.001894 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] ActionID: 32260544_11#3.. ## T +0.001223 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Message: Originate successfully queued.... # T +0.005362 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Event: Newexten..Privilege: call,all..Channel: SIP/210-b027..Context: = trc..Extension: 304..Prio rity: 2..Application: Ringing..AppData: ..Uniqueid: 1173952443.0.... ## T +0.070978 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Event: Newexten..Privilege: call,all..Channel: SIP/210-b027..Context: = trc..Extension: 304..Prio rity: 3..Application: Wait..AppData: 30..Uniqueid: 1173952443.0.... # T +0.079071 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Event: Newchannel..Privilege: call,all..Channel: = IAX2/faktortel-5..State: Down..CallerID: <unkn own>..CallerIDName: <unknown>..Uniqueid: 1173952450.1.... ## T +0.003277 192.168.0.103:2081 -> 192.168.0.110:5038 [AP] action: GetVar..actionid: 32260544_12#..variable: trcCallID..channel: = IAX2/faktortel-5.... # T +0.001136 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Response: Success..Variable: trcCallID..Value: .. # T +0.000131 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] ActionID: 32260544_12#.. # T +0.000119 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] .. ## T +0.058156 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Event: Newcallerid..Privilege: call,all..Channel: = IAX2/faktortel-5..CallerID: <Unknown>..Caller IDName: <Unknown>..Uniqueid: 1173952450.1..CID-CallingPres: 0 = (Presentation Allowed, Not Screen ed).... ## T +0.078445 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Event: Newchannel..Privilege: call,all..Channel: = IAX2/faktortel-5..State: Ringing..CallerID: <u nknown>..CallerIDName: <unknown>..Uniqueid: 1173952450.1.... # T +0.011187 192.168.0.103:2081 -> 192.168.0.110:5038 [AP] action: GetVar..actionid: 32260544_13#..variable: trcCallID..channel: = IAX2/faktortel-5.... # T +0.021240 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Response: Error.. # T +0.000141 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] ActionID: 32260544_13#.. # T +0.000109 192.168.0.110:5038 -> 192.168.0.103:2081 [AP] Message: No such channel.... ### *************************************************************************= ************************* NGREP OUTPUT: what follows is a failure to retreive the channel variable *************************************************************************= *********************** T +0.065913 192.168.0.103:2171 -> 192.168.0.110:5038 [AP] action: Originate..actionid: 14220570_11#3..timeout: 30000..exten: = 303..async: true..variable: room=3D3750..variable: trcCallID=3D3..variable: = options=3DqdxA..context: trc..priority: 1..channel: I AX2/09508696@faktortel/94044931.... # T +0.004425 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Response: Success.. # T +0.001197 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] ActionID: 14220570_11#3.. ## T +0.001863 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Message: Originate successfully queued.... ## T +0.269368 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Event: Newexten..Privilege: call,all..Channel: SIP/210-7e81..Context: = trc..Extension: 304..Prio rity: 2..Application: Ringing..AppData: ..Uniqueid: 1173952739.2.... # T +0.002325 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Event: Newexten..Privilege: call,all..Channel: SIP/210-7e81..Context: = trc..Extension: 304..Prio rity: 3..Application: Wait..AppData: 30..Uniqueid: 1173952739.2.... ## T +0.002692 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Event: Newchannel..Privilege: call,all..Channel: = IAX2/faktortel-5..State: Down..CallerID: <unkn own>..CallerIDName: <unknown>..Uniqueid: 1173952743.3.... # T +0.002628 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Event: Newcallerid..Privilege: call,all..Channel: = IAX2/faktortel-5..CallerID: <Unknown>..Caller IDName: <Unknown>..Uniqueid: 1173952743.3..CID-CallingPres: 0 = (Presentation Allowed, Not Screen ed).... ## T +0.005310 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Event: Newchannel..Privilege: call,all..Channel: = IAX2/faktortel-5..State: Ringing..CallerID: <u nknown>..CallerIDName: <unknown>..Uniqueid: 1173952743.3.... ## T +0.493871 192.168.0.103:2171 -> 192.168.0.110:5038 [AP] action: GetVar..actionid: 14220570_12#..variable: trcCallID..channel: = IAX2/faktortel-5.... # T +0.001254 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Response: Success..Variable: trcCallID..Value: 3.. # T +0.000122 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] ActionID: 14220570_12#.. # T +0.000170 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] .. ### T +0.501307 192.168.0.103:2171 -> 192.168.0.110:5038 [AP] action: GetVar..actionid: 14220570_13#..variable: trcCallID..channel: = IAX2/faktortel-5.... # T +0.001883 192.168.0.110:5038 -> 192.168.0.103:2171 [AP] Response: Success..Variable: trcCallID..Value: 3.. # *************************************************************************= ************************* |
From: Stefan R. <ste...@re...> - 2007-03-15 10:54:06
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Robert Sutton wrote: > Does anyone have a better solution to this problem. The originate methods in org.asteriskjava.live.AsteriskServer do more or less the same. Can you use them instead of your homebrewn code? If you can and the problem persists I am happy to dig into it and find a solution that will benefit the whole community. You might also want to use the latest milestone, i.e. 0.3-m2. Best regards, 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF+SXCcVCZDfrn+pMRAiELAJ9+u3jfYSN+jJHFOGjzgtx6zh+PAACffRNG vXaARCcCxCERWRvcYGwn3tE= =MVY9 -----END PGP SIGNATURE----- |