我将Asterisk-Manager软件包用于NodeJ
https://www.npmjs.com/package/asterisk-manager
和Phoner
用于测试目的。我想使用此代码测试通话功能
const asterisk = require('asterisk-manager');
const { port, host, user, password, events } = require('../config.json').phone;
const ami = new asterisk(port, host, user, password, events);
ami.keepConnected();
module.exports = () => {
if (!ami.isConnected()) {
console.log(`Phone is not connected, trying to connect`);
ami.connect();
if (!ami.isConnected()) {
throw Error(`Failed to connect`);
} else {
console.log(`Connected successfully`);
}
}
ami.action({
action: 'originate',
channel: 'SIP/phonerUser',
context: 'internal',
exten: 1337,
priority: 1
}, (err, res) => {
console.log(err);
console.log(res);
});
};
但未执行原始操作。该代码未命中回调函数,因此我什至无法记录错误。当我尝试登录
ami.isConnected()
在调用该动作之前,我会得到一个 true 。我想念什么吗?