Am currently developing a mute function for asterisk which I can run from my web front end using asterisk ARI.
But every time I try to run/call the mute function it gives me the following error:
Error: {
"message": "Channel not in Stasis application"
}
But it is, as far as am aware am passing the channel data directly to this function but to no avail.
Any one any suggestions or used to working with the ARI JS client?
Client Side
When mute button is clicked emit the data found in td to the server side.
$(document).on('click', '.mute', function () {
var mute = $(this).closest('td').siblings(':first-child').text();
socket.emit('muting', mute);
if ($(this).hasClass('mute')) {
$(this).removeClass('mute').addClass('unmute').find('span').text('Unmute');
} else {
console.log("Error");
}
});
Server Side
Store the data received from client side into a var and then call the stasis function.
io.sockets.on('connection', function (socket) {
updateSip();
socket.on('muting', function (data) {
mute(data);
console.log("Reached listener for muting")
});
});
Stasis function
Mute the channel which you have just passed from client to server side using ARI client commands, user will be muted and will show in stasis application.
function mute(mutval) {
console.log("Muting:" + mutval);
client.channels.mute
({
channelId : mutval
},
function (err) {
if (err) {
throw err;
}
});
}
The channel is in the application and being passed to the mute function, so am not sure as to way its not working currently.
EDIT: I have a hangup/kick function being handled in the same way and it works fine. Below is all my debugging.
Channel Dump
Free PBX Logs Asterisk CLI Debug Level 5
Socket.io Error
I have also tried running it via socket.io and without it and the outcome is the same, I have other functions and they all work just fine, its just the mute function.
Turns out it would not run because it needed channel ID and not channel name, but functions would run with channel name.
It is inconsistency with the Asterisk ARI as it should work with channel name and not just channel ID like other functions did such as hangup and originate functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With