Asterisk - ARI - multiple applications connected to asterisk on the same stasis app

Hello,
I have a scenario where i have multiple server applications i developed connecting to asterisk 13.
When the second server connects to it, it seems to be replacing the communication and the first server stops working.

  1. When first server connects on app “agent-request”

Activating Stasis app ‘agent-request’
== WebSocket connection from ‘192.168.127.219:39654’ for protocol ‘’ accepted using version '13’
Activating Stasis app ‘agent-request’

  1. When second server connects on the same app “agent-request”

Channel PJSIP/clickproxytrunk-0000043a joined ‘simple_bridge’ stasis-bridge <70>
Replacing Stasis app ‘agent-request’
== WebSocket connection from ‘192.168.127.22:49416’ for protocol ‘’ accepted using version '13’
Activating Stasis app ‘agent-request’

As the CLI displays the message “Replacing Stasis app ‘agent-request’”, it gives me a hint that the first server won’t receive any websocket messages anymore.

Can you please explain me what should I do in order to have multiple servers communicating with asterisk 13 and sending/receiving messages independently ?

Well, after discussing that issue here in my company, we understand this is the expected behavior. When the second server connected, asterisk handled the control of that stasis to it. There is nothing we can do about it.
So we will change our testing process here to have one application server for each asterisk installation.

Do you agree with that?

That is how it works, yes. There is no capacity inside of Asterisk to have multiple Stasis applications connected using the same name.

1 Like

That means i cannot use a stasis app simultaneously for multiple calls?
What to do if I need that?

Multiple calls can be handled by the same stasis application. Events occur over the same Websocket for each.

In my case it seems the second call (to the same extension number) is somehow interrupting the first call. When i answer the call nothing happens … (an audio file should be played).

Creating Stasis app 'procall'
  == WebSocket connection from '192.168.240.1:53721' for protocol '' accepted using version '13'
    -- Called 44448888
    -- PJSIP/44448888-000000e8 is ringing
 Replacing Stasis app 'procall'
  == WebSocket connection from '192.168.240.1:53864' for protocol '' accepted using version '13'
    -- Called 44448888
       > 0x7f654c00dc20 -- Strict RTP learning after remote address set to: 10.16.191.145:4034
    -- PJSIP/44448888-000000e8 answered
       > Launching Stasis(procall) on PJSIP/44448888-000000e8
       > 0x7f654c00dc20 -- Strict RTP qualifying stream type: audio
       > 0x7f654c00dc20 -- Strict RTP switching source address to 192.168.240.1:4034
       > 0x7f654c00dc20 -- Strict RTP learning complete - Locking on source address 192.168.240.1:4034

That would be due to your application itself. In this case it seems it reconnected to the Websocket which displaced the first.

That’s interesting. I know it’s not your product or topic but the documentation for ari4java says:

Create a new channel (originate). The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further events and updates.

Is originate the wrong REST method in this case?

If reusing a stasis app, “Replacing Stasis app 'xy” shouldn’t occur I guess?

Right. The “Replacing” occurs when a new Websocket is established to Asterisk with the same application name.