Trying To Create An ExternalIVR Wrapper

So now I’m trying to add an ExternalIVR wrapper to my Seaskirt module. But Asterisk seems to be losing entries in the audio queue. (This is with the Asterisk 20.6 package in an Ubuntu 24.04 container.)

Things start up OK: I can send a few requests (query parameters, play a welcome message) and receive events:

DEBUG:asterisk-seaskirt:sending request line: 'L,IVR says hi'
DEBUG:asterisk-seaskirt:sending request line: 'P,.'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/dir-welcome'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('P', 1744699743, 'ivr://127.0.0.1:2949,some,data')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699745, '/usr/share/asterisk/sounds/en/dir-welcome')

The user can press a key, and my script responds with a voice confirmation of which key was pressed:

INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('1', 1744699747, None)
DEBUG:asterisk-seaskirt:sending request line: 'S,/usr/share/asterisk/sounds/en/calling'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/1'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699748, '/usr/share/asterisk/sounds/en/calling')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699749, '/usr/share/asterisk/sounds/en/digits/1')

So long as I don’t try to queue up more than 2 sound files at a time, they seem to play OK:

INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('2', 1744699755, None)
DEBUG:asterisk-seaskirt:sending request line: 'S,/usr/share/asterisk/sounds/en/calling'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/2'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699756, '/usr/share/asterisk/sounds/en/calling')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699757, '/usr/share/asterisk/sounds/en/digits/2')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('3', 1744699761, None)
DEBUG:asterisk-seaskirt:sending request line: 'S,/usr/share/asterisk/sounds/en/calling'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/3'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699762, '/usr/share/asterisk/sounds/en/calling')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699762, '/usr/share/asterisk/sounds/en/digits/3')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('1', 1744699767, None)
DEBUG:asterisk-seaskirt:sending request line: 'S,/usr/share/asterisk/sounds/en/calling'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/1'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699768, '/usr/share/asterisk/sounds/en/calling')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699769, '/usr/share/asterisk/sounds/en/digits/1')

Try queuing up 3 files, and it starts losing track:

INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('2', 1744699770, None)
DEBUG:asterisk-seaskirt:sending request line: 'S,/usr/share/asterisk/sounds/en/calling'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/1'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/2'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699771, '/usr/share/asterisk/sounds/en/calling')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699771, '/usr/share/asterisk/sounds/en/digits/1')

Wait a few seconds for it to say “two”, but I hear nothing more. So I try to go back to queueing just 2 audio files:

INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('4', 1744699783, None)
DEBUG:asterisk-seaskirt:sending request line: 'S,/usr/share/asterisk/sounds/en/calling'
DEBUG:asterisk-seaskirt:sending request line: 'A,/usr/share/asterisk/sounds/en/digits/4'
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('D', 1744699783, '/usr/share/asterisk/sounds/en/digits/2')
INFO:asterisk-ivr-dtmf-demo:Got IVR event: ('F', 1744699784, '/usr/share/asterisk/sounds/en/calling')

Note that notification of the deletion of the queue entry which was supposed to be played but was not. And then it says “calling” as the first entry of the new queue, but it never gets around to saying the actual digit.

It’s always possible my code is wrong. But I put in extensive debugging precisely to be sure about what Asterisk is doing. And the audio I hear on the SIP client (I’m using Twinkle) corresponds to the event notifications my script is reporting. That gives me confidence that my script is doing the right thing, while Asterisk is not. Does it look that way to you?

I have got it working reliably by implementing my own queueing of audio files. This way, Asterisk only ever has to deal with playing a single audio file at a time. I watch for its playback completed/aborted events in order to manage my queue.

You can see the code in the ivr_dtmf_demo script in my seaskirt_examples repo.