ARI Dialing Node JS

Hi All,

I am using node are a client for ARI communication,
I wrote a program with node js for dialing and play sound.
Actually It is working fine, But When call pickup then the program terminates with an error.
I am shared programs and errors with this mail.
I need support

Thanks
Praveen

-------------------------------------Program---------------------------------------
/jshint node:true/

‘use strict’;

var ari = require(‘ari-client’);

var util = require(‘util’);

ari.connect(‘http://192.168.1.107:8088’, ‘asterisk’, ‘asterisk’, clientLoaded);

// handler for client being loaded

function clientLoaded (err, client) {

if (err) {

throw err;

}

client.channels.originate(

{app: 'channel-test', endpoint: 'PJSIP/6001',callerId :'8009',appArgs: 'dialed'},

function (err, channel) {

  if(err){

    throw  err;



  }

}

);

client.channels.list(function(err, channels) {

if (!channels.length) {

  console.log('No channels currently :-(');

} else {

  console.log('Current channels:');

  channels.forEach(function(channel) {

    console.log(channel.name);

    console.log(channel.id);

  });

}

});

// handler for StasisStart event

function stasisStart(event, channel) {

console.log(util.format(

    'Channel %s has entered the application', channel.name));

    channel.dial(channel,

   

      function (err) {

        throw err;

      }

   

    );

  channel.answer(function(err) {

      if (err) {

        throw err;

      }

    });

    var playback = client.Playback();

    channel.play({media: 'sound:tt-monkeys'},

                  playback, function(err, newPlayback) {

      if (err) {

        throw err;

      }

    });

    playback.on('PlaybackFinished', playbackFinished);



function playbackFinished(event, completedPlayback) {

  console.log(util.format(

      'Monkeys successfully vanquished %s; hanging them up',

      channel.name));

  channel.hangup(function(err) {

    if (err) {

      throw err;

    }

  });

}

}

// handler for StasisEnd event

function stasisEnd(event, channel) {

console.log(util.format(

    'Channel %s has left the application', channel.name));

}

function channelStateChange(event, channel) {

console.log(util.format(

      'Channel %s is now: %s', channel.name, channel.state));

}

client.on(‘StasisStart’, stasisStart);

client.on(‘StasisEnd’, stasisEnd);

client.on(‘ChannelStateChange’, channelStateChange);

client.start(‘channel-test’);

}


Error-------

You can’t call “dial” on the channel because it is already dialed and answered.

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