Res_stasis.c cannot find app by name issue

I am currently having an issue with asterisk running ARI applications, where if asterisk has just started or been restarted the application doesn’t load properly and cannot catch states giving the below error before creating the stasis app.

[2016-05-17 10:02:07] WARNING[2777]: res_stasis.c:1446 find_app_by_name: Could not find app 'ARI-Metric-App'
[2016-05-17 10:02:07] WARNING[2778]: res_stasis.c:1446 find_app_by_name: Could not find app 'ARI-Metric-App'
 Creating Stasis app 'ARI-Metric-App'
  == WebSocket connection from '[::1]:41165' for protocol '' accepted using version '13'
 Activating Stasis app 'ARI-Metric-App'

Am not sure if modules are loading slowly, or if asterisk needs to be up a certain amount of time before stasis applications work accordingly and even after 20 odd minutes it could still not connect.

On my local VM this isn’t an issue because it doesn’t take that long for the modules to load I think and my stasis apps work grand. But when moving it and trying it on another container and trying it it takes a long time and I find my self spamming the opening of the application and hoping it works accordingly so states can be caught.

Anyone advise on the issue, is it how modules are being loaded or does asterisk need to up a certain amount of time?

What is the complete console output when this happens, not just the small fragment amount?

Below is literally all we getting back.

root@hpbxwo439:~# asterisk -rvvvvvvv
Asterisk 13.8.0, Copyright (C) 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.
=========================================================================
Connected to Asterisk 13.8.0 currently running on hpbxwo439 (pid = 5780)
[2016-05-17 11:22:25] WARNING[21583]: res_stasis.c:1446 find_app_by_name: Could not find app ‘ARI-Metric-App’
[2016-05-17 11:22:25] WARNING[21584]: res_stasis.c:1446 find_app_by_name: Could not find app ‘ARI-Metric-App’
Creating Stasis app ‘ARI-Metric-App’
== WebSocket connection from ‘127.0.0.1:52034’ for protocol ‘’ accepted using version ‘13’
Activating Stasis app ‘ARI-Metric-App’
hpbxwo439*CLI>

So Asterisk does appear to be started, then? If so create an issue on the issue tracker[1] with COMPLETE details. This is certainly not something I’ve heard about from anyone else.

[1] https://issues.asterisk.org/jira

Turns out that when your subscribing to events the application sometimes does not load before you subscribe to events due to the asynchronous nature of node.

Causing that issue E.G solution as below:

function startsub(){
console.log(“------------------------------------------------------------”)
console.log(‘starting up ARI subsciptions’)
client.applications.subscribe({
applicationName : stasisApp,
eventSource : eventendpoint
},
function (err, application) {
console.log('Subscribed to ’ + eventendpoint);
});

client.applications.subscribe({
applicationName : stasisApp,
eventSource : eventdevicestate
},
function (err, application) {
console.log('Subscribed to ’ + eventdevicestate);
});
}
client.start(stasisApp);
startsub();

The client.start was sometimes staring first…but most of the time was starting after subscriptions were being made.

Ah, I did not know you were subscribing. Yes. Asynchronous is fun. You need to ensure that the WebSocket connection is established first before subscribing.