Function is not executed

I use the Asterisk-Manager package for NodeJs

and Phoner

http://phoner.de/index_en.htm

for testing purposes. I want to test the call functionality using this code

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);

    });
};

but the originate action is not executed. The code does not hit the callback function so I can’t even log an error. When I try to log

ami.isConnected()

before calling the action I get a true. Am I missing something?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.