Asterisk Stasis application on crash

Hello,

We have a very basic Stasis application setup.

exten => 8000,1,noop("Incoming call")
 same => n,stasis(hello-world)
 same => n,hangup(16)

We’re getting a behaviour we’re trying to understand. When we call in to our stasis app and exit our python app (the ws subscriber), the call terminates after ~5 seconds. This is despite us sending an /answer.

But if we start MoH on the channel id, then exit our python app the call remains in the stasis and will remain there until we can re-open our app.

Attaching our python code for convenience. If we would call on_start_survive() instead of on_start() the call would survive the app crash/restart.

#!/usr/bin/python3
import asyncio
import websockets
import requests
import json

class ARIParser:

    def __init__(self):
        self.ari = ARIRequester()
    
    def parse_event(self, ari_event : str) -> None:
        # ARI Event dictionary
        message = json.loads(ari_event)
        
        # Channel id xxxxxxxxxxx.yyyyyy
        channel_id = channel_id

        if message["type"] == "StasisStart":
            """ A new call entered our stasis app """
            self.ari.on_start(channel_id)

class ARIRequester:

    def on_start(self, channel_id : str) -> None:
        """ Answer channel """
        r = requests.post(f"http://localhost:8088/ari/channels/{channel_id}/answer", auth=('X', 'Y'))
    
    def on_start_survive(self, channel_id : str) -> None:
        """ Answer channel AND start MoH"""
        r = requests.post(f"http://localhost:8088/ari/channels/{channel_id}/answer", auth=('X', 'Y'))
        r = requests.post(f"http://localhost:8088/ari/channels/{channel_id}/moh?mohClass=default", auth=('X', 'Y'))

async def subscribe():
    async with websockets.connect(f"ws://localhost:8088/ari/events?api_key=X:Y&app=hello-world") as websocket:
        async for message in websocket:
            parser.parse_event(message)

parser = ARIParser()

asyncio.get_event_loop().run_until_complete(subscribe())

What makes the call in our case survive our Python app crash/restart? And what makes it terminate?

I think we MAY have encountered some type of timeout when the call enter the stasis application. It seems to hangup no matter what we do after 8-10s unless we start a playback, moh etc. on the channel.

Is there a timeout like this?

Have you looked at who is hanging up the call? (pjsip set logger on). It could very well be the remote side.

Yep, you are right. There appears to be an RTP timeout upstream.

So either we have to start with MoH or indicate ringing to get the RTP flowing to avoid this. Unless there is a better way of doing this.