2

I am using Asterisk Java to make calls to various numbers via SIP channels

originateAction.setChannel("SIP/10.0.66.118/0900044314");

But when it comes to event the Channel changes to SIP/10.0.66.118-0000003f

Please suggest how to link the event with the Originate action as in DAHDI it shows channel with called number.

Manager Event is-->org.asteriskjava.manager.event.NewChannelEvent[dateReceived=Tue Jul 21 18:45:14 IST 2015,privilege='call,all',timestamp='null',calleridname='null',uniqueid='1437484937.66',callerid='null',state='null',calleridnum='null',channel='SIP/10.0.66.118-0000003f',systemHashcode=90910501]
Manager Event is-->org.asteriskjava.manager.event.NewCallerIdEvent[dateReceived=Tue Jul 21 18:45:14 IST 2015,privilege='call,all',timestamp='null',calleridname='null',uniqueid='1437484937.66',callerid='6131000',cidcallingpres='0',cidcallingprestxt='Presentation Allowed, Not Screened',calleridnum='6131000',channel='SIP/10.0.66.118-0000003f',systemHashcode=473578347]
Manager Event is-->org.asteriskjava.manager.event.NewChannelEvent[dateReceived=Tue Jul 21 18:45:15 IST 2015,privilege='call,all',timestamp='null',calleridname='null',uniqueid='1437484938.67',callerid='null',state='null',calleridnum='null',channel='SIP/10.0.66.118-00000040',systemHashcode=856882247]
Manager Event is-->org.asteriskjava.manager.event.NewCallerIdEvent[dateReceived=Tue Jul 21 18:45:15 IST 2015,privilege='call,all',timestamp='null',calleridname='null',uniqueid='1437484938.67',callerid='6131000',cidcallingpres='0',cidcallingprestxt='Presentation Allowed, Not Screened',calleridnum='6131000',channel='SIP/10.0.66.118-00000040',systemHashcode=594588547]
Manager Event is-->org.asteriskjava.manager.event.NewStateEvent[dateReceived=Tue Jul 21 18:45:18 IST 2015,privilege='call,all',timestamp='null',calleridname='null',uniqueid='1437484937.66',callerid='6131000',state='null',calleridnum='6131000',channel='SIP/10.0.66.118-0000003f',systemHashcode=703599489]
Manager Event is-->org.asteriskjava.manager.event.HangupEvent[dateReceived=Tue Jul 21 18:45:44 IST 2015,privilege='call,all',timestamp='null',calleridname='<unknown>',uniqueid='1437484937.66',callerid='6131000',causetxt='User alerting, no answer',cause='19',state='null',calleridnum='6131000',channel='SIP/10.0.66.118-0000003f',systemHashcode=1275756078]
Manager Event is-->org.asteriskjava.manager.event.OriginateResponseEvent[dateReceived=Tue Jul 21 18:45:44 IST 2015,privilege='call,all',reason='3',response='Failure',calleridname='<unknown>',timestamp='null',uniqueid='<null>',actionid='null',internalactionid='498357308_6',context='from-pstn',exten='84',calleridnum='6131000',channel='SIP/10.0.66.118/08755862255',systemHashcode=771938640]
Manager Event is-->org.asteriskjava.manager.event.HangupEvent[dateReceived=Tue Jul 21 18:45:45 IST 2015,privilege='call,all',timestamp='null',calleridname='<unknown>',uniqueid='1437484938.67',callerid='6131000',causetxt='User alerting, no answer',cause='19',state='null',calleridnum='6131000',channel='SIP/10.0.66.118-00000040',systemHashcode=1024010953]
Manager Event is-->org.asteriskjava.manager.event.OriginateResponseEvent[dateReceived=Tue Jul 21 18:45:45 IST 2015,privilege='call,all',reason='3',response='Failure',calleridname='<unknown>',timestamp='null',uniqueid='<null>',actionid='null',internalactionid='1655137665_6',context='from-pstn',exten='5',calleridnum='6131000',channel='SIP/10.0.66.118/09910044314',systemHashcode=618140013]
Manager Event is-->org.asteriskjava.manager.event.RegistryEvent[dateReceived=Tue Jul 21 18:47:34 IST 2015,privilege='system,all',timestamp='null',username='6131000',cause='null',channeldriver='null',status='Registered',domain='10.0.66.118',channel='null',systemHashcode=156354047]

Plz suggest .

Anuj Kumar
  • 23
  • 5

2 Answers2

0

In my C# application, which also use AMI, with originate action I set some variable with my own unique identifier, and then track the VarSet event to bind UniqueId of the call to my own ID that is specified in this variable. Then using UniqueId you can track any events of the call.

In your case you need to do something like

originateAction.setVariable('myOwnId=myUniqueValue');

and listen to VarSet event: https://github.com/asterisk-java/asterisk-java/blob/master/src/main/java/org/asteriskjava/manager/event/VarSetEvent.java

Then you can check variable and value fields, and if it's equals your values, remember uniqueId value.

And there is another way to bind you originate action with UniqueId - OriginateResponse event.

Vladimir Shiyanov
  • 1,236
  • 16
  • 18
  • 1
    Hi , But you own Variable doesnt appear in Event Trace ? Like New Event Trace `.NewChannelEvent[dateReceived=Tue Jul 21 18:45:14 IST 2015,privilege='call,all',timestamp='null',calleridname='null',uniqueid='1437484937.66',callerid='null',state='null',calleridnum='null',channel='SIP/10.0.66.118-0000003f',systemHashcode=90910501]` – Anuj Kumar Jul 23 '15 at 03:11
  • How can you link the originateAction.setChannel("SIP/10.0.66.118/0900044314") --> to SIP event as generally the calling no -->0900044314--> Unique ID--> Events. Is there a way to get Uqique id while Originate action – Anuj Kumar Jul 23 '15 at 03:18
  • 1
    There is one way to link originate action with UniqueId - it's OriginateResponse event, and also you can bind it via channel variable. I don't understand what are you mean "doesn't appear in Event Trace", but both of VarSet and OriginateResponse events is exactly support by asterisk-java. Look at editions of my answer. May be now it's better to undestand. – Vladimir Shiyanov Jul 23 '15 at 14:55
  • This is event string --> (channel doesnt show originated number) `INFO: No event class registered for event type 'varset', attributes: {uniqueid=1437876389.147733, event=VarSet, privilege=dialplan,all, value=SUCCESS, variable=PLAYBACKSTATUS, channel=SIP/10.0.66.118-00000c83}` my code ` originateResponse = managerConnection.sendAction(originateAction,60000);//,sleep_time_for_call); System.out.print("O Response is --> "+originateResponse.getUniqueId());` getUniqueId gives null – Anuj Kumar Jul 26 '15 at 02:41
  • Did you add your custom variable in originate action (originateAction.setVariable('myOwnId=myUniqueValue'))? – Vladimir Shiyanov Jul 27 '15 at 07:47
  • `originateAction.setAsync(true); Random rnd = new Random(); originateAction.setAccount(campaign_id); originateAction.setExten(Integer.toString(rnd.nextInt(99))); originateAction.setPriority(new Integer(1)); originateAction.setVariable("filename","/home/project/upload/kisaan/"+f);`I have set a user defined variable which passes a filename to be played . And event string doesnt have a mention of this variable . – Anuj Kumar Jul 27 '15 at 17:30
  • Problem only with the event or variable is also not set? Maybe this is an issue of library. Did you try to connect manager directly from telnet? VarSet event tracked? – Vladimir Shiyanov Jul 27 '15 at 18:47
  • "Problem only with the event" with all event as they dont show the dialed msisdn "variable is also not set" variable set happens `INFO: No event class registered for event type 'varset', attributes: {uniqueid=1437876389.147733, event=VarSet, privilege=dialplan,all, value=SUCCESS, variable=PLAYBACKSTATUS, channel=SIP/10.0.66.118-00000c83}` Problem is not of event string ... but matching the session with originate function – Anuj Kumar Aug 03 '15 at 15:27
-1
UniqueId = "";
var originateResponse = manager.SendEventGeneratingAction(oc, oc.Timeout);
if (originateResponse.Events.Count > 0 && originateResponse.Events[0].UniqueId != null && originateResponse.Events[0].UniqueId != "<unknown>")
{
    UniqueId = originateResponse.Events[0].UniqueId;
}