我有一个java / asterisk应用程序,它扫描联系人数据库,按顺序调用它们,并将它们连接到一个提供一些交互的扩展。 我已经做了一些测试,现在它可以正常使用SIP(本地IP电话和Skype)。 上周我收到了我的电话板并配置了它(与Dahdi一起)。通过IP Phone拨打电话直接测试。完美的工作。所以我设置我的程序来使用我的卡的FXO模块。现在它不起作用。
使用OriginateAction生成调用。以下是代码:
public class OriginateCall {
private ManagerConnection managerConnection;
public void run() throws
IOException,AuthenticationFailedException,TimeoutException, ClassNotFoundException, SQLException {
//Prepare the call
OriginateAction originateAction;
originateAction=new OriginateAction();
originateAction.setChannel(Constants.PHONE_NUMBER_PREFIX+phoneNumber+Constants.PHONE_NUMBER_SUFFIX);
originateAction.setExten(Constants.SCRIPT_EXTENSION);
originateAction.setContext(Constants.DIALPLAN_CONTEXT);
originateAction.setPriority(new Integer(1));
System.out.println(originateAction);
//connect to Asterisk and login
ManagerConnectionFactory factory = new ManagerConnectionFactory(Constants.ASTERISK_URL,
Constants.ASTERISK_USERNAME, Constants.ASTERISK_PASSWORD);
managerConnection = factory.createManagerConnection();
managerConnection.login();
//send the originate action and wait for a maximum of 30 seconds to get a response
ManagerResponse managerResponse;
try {
managerResponse = managerConnection.sendAction(originateAction, Constants.TIMEOUT);
System.out.println(managerResponse);
}
catch (TimeoutException e){
System.out.println("No answer");
}
//log off and disconnect
managerConnection.logoff();
}
}
如您所见,我创建了一些调试输出。我在控制台中看到的是:
org.asteriskjava.manager.action.OriginateAction[action='Originate',application='null',callerid='null',data='null',actioncompleteeventclass='class org.asteriskjava.manager.event.OriginateResponseEvent',callingpres='null',async='null',variables='{contactId=4, rights=1111, messageId=18, attempts=1, callLogId=95, newShareLogId=19, fromShareLogId=0}',actionid='null',codecs='null',priority='1',context='gomobile',exten='700',account='null',channel='DAHDI/G0/00212*********',timeout='null',systemHashcode=1290874036]
Feb 17, 2014 5:42:00 PM org.asteriskjava.manager.internal.ManagerConnectionImpl connect
INFO: Connecting to localhost:5038
Feb 17, 2014 5:42:00 PM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
INFO: Connected via Asterisk Call Manager/1.3
Feb 17, 2014 5:42:00 PM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
WARNING: Unsupported protocol version 'Asterisk Call Manager/1.3'. Use at your own risk.
Feb 17, 2014 5:42:00 PM org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
INFO: Successfully logged in
Feb 17, 2014 5:42:00 PM org.asteriskjava.manager.internal.EventBuilderImpl buildEvent
INFO: No event class registered for event type 'fullybooted', attributes: {status=Fully Booted, event=FullyBooted, privilege=system,all}. Please report at http://jira.reucon.org/browse/AJ
Feb 17, 2014 5:42:02 PM org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
INFO: Determined Asterisk version: Asterisk 1.6
org.asteriskjava.manager.response.ManagerResponse: actionId='null'; message='Originate successfully queued'; response='Success'; uniqueId='null'; systemHashcode=977552923
Feb 17, 2014 5:42:06 PM org.asteriskjava.manager.internal.EventBuilderImpl buildEvent
INFO: No event class registered for event type 'dahdichannel', attributes: {dahdichannel=2, dahdispan=1, uniqueid=1392658922.12, sequencenumber=133, file=chan_dahdi.c, event=DAHDIChannel, privilege=call,all, line=2250, func=dahdi_ami_channel_event, channel=DAHDI/2-1}. Please report at http://jira.reucon.org/browse/AJ
Feb 17, 2014 5:42:06 PM org.asteriskjava.manager.internal.ManagerConnectionImpl disconnect
INFO: Closing socket.
Feb 17, 2014 5:42:06 PM org.asteriskjava.manager.internal.ManagerReaderImpl run
INFO: Terminating reader thread: No more lines available: Scanner closed
有关信息。我在OriginateAction对象(DAHDI / G0 / 00212xxxxxxxxx)中看到的通道与我在拨号方案扩展中使用的通道完全相同,并且从IP电话调用时效果非常好。
以下是星号cli的输出:
== Manager 'manager' logged on from 127.0.0.1
-- Executing [700@gomobile:1] WaitForSilence("DAHDI/2-1", "5000") in new stack
-- Waiting 1 time(s) for 5000 ms silence with 0 timeout
== Manager 'manager' logged off from 127.0.0.1
-- Exiting with 5000ms silence >= 5000ms required
-- Executing [700@gomobile:2] AGI("DAHDI/2-1", "agi://localhost/message.agi") in new stack
-- Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/hello' (escape_digits=) (sample_offset 0)
-- Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/ziggi-speaking' (escape_digits=) (sample_offset 0)
-- Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/listen-to-this-joke' (escape_digits=) (sample_offset 0)
-- Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Messages/20' (escape_digits=) (sample_offset 0)
-- Playing 'silence/1' (escape_digits=) (sample_offset 0)
-- AGI Script Executing Application: (Background) Options: (/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/tell-the-truth&/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/did-you-laugh&/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/if-you-like&/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/press-1&/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/like-share&/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/press-2&silence/2)
-- <DAHDI/2-1> Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/tell-the-truth.gsm' (language 'en')
-- <DAHDI/2-1> Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/did-you-laugh.gsm' (language 'en')
-- <DAHDI/2-1> Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/if-you-like.gsm' (language 'en')
-- <DAHDI/2-1> Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/press-1.gsm' (language 'en')
-- <DAHDI/2-1> Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/like-share.gsm' (language 'en')
-- <DAHDI/2-1> Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/press-2.gsm' (language 'en')
-- <DAHDI/2-1> Playing 'silence/2.gsm' (language 'en')
-- Playing 'silence/1' (escape_digits=) (sample_offset 0)
-- Playing 'silence/1' (escape_digits=) (sample_offset 0)
-- Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/good-bye' (escape_digits=) (sample_offset 0)
-- Playing '/home/gomobile/Documents/Gomobile/Sound files/Preliminary/Menu/i-prepare-a-joke-and-call-you-back' (escape_digits=) (sample_offset 0)
-- <DAHDI/2-1>AGI Script agi://localhost/message.agi completed, returning 4
== Spawn extension (gomobile, 700, 2) exited non-zero on 'DAHDI/2-1'
-- Executing [h@gomobile:1] NoOp("DAHDI/2-1", "hang up") in new stack
-- Executing [h@gomobile:2] Set("DAHDI/2-1", "hangedUp=1") in new stack
-- Executing [h@gomobile:3] AGI("DAHDI/2-1", "agi://localhost/cleanup.agi") in new stack
-- <DAHDI/2-1>AGI Script agi://localhost/cleanup.agi completed, returning 0
-- Hanging up on 'DAHDI/2-1'
-- Hungup 'DAHDI/2-1'
这里有一个奇怪的地方:我从未在cli中看到拨打过的电话号码。 接下来发生的事情是手机(我的手机)永远不会响。扩展程序700开始播放(我最终理解这是正常的,因为使用FXO时,一旦将其传递给Asterisk,通道就被视为已回答),但它仅在服务器内播放。没有电话。
任何人都可以提供帮助吗?