Hello, community members.
I’ve reviewed existing community posts and worked hard to solve the problem using AI, but I couldn’t resolve it, so I’m asking here.
What I’m Developing
I’m developing a service that transcribes and translates call audio.
Implementation Method
Using Asterisk 16, I created an ARI client application. I use externalmedia and snoop to send call audio to an external application,
and I use a different externalmedia to feed audio received from the external application back into the main call bridge.
Development Environment
ARI Client App: Node.js
Asterisk: 16.15.1
The Asterisk server is hosted on AWS EC2, while the external SIP-GW resides on a separate network.
Therefore, both internal and external calls are routed through the SIP-GW.
The Asterisk server and SIP-GW communicate via VPN.
Issue
There are three call patterns: internal-to-internal, external-to-internal, and internal-to-external.
During internal-to-external calls, the moment the external terminal rings and is answered,
a hangup request occurs, abruptly ending the call.
Internal-to-internal and external-to-internal calls function correctly, but the issue occurs only with internal-to-external calls.
Tracking logs from the CLI and client applications revealed the following sequence occurring within milliseconds:
- The client application originates the external call.
- External GW responds: The external GW returns a
200 OKand waits on RTP port16908. - Asterisk sends an ACK: The call is established.
- Bridge technology switch:
switching from simple_bridge technology to native_rtp- (Immediately afterward, Snoop starts)
switching from native_rtp technology to simple_bridge
- Asterisk immediately sends Re-invite: Asterisk changes its receiving port to
10640and re-sends to the external GW. - External GW sends BYE: Disconnects with
X-Asterisk-HangupCauseCode: 58.
Steps Taken for Improvement
The following actions were attempted, but did not resolve the issue; the call still disconnects with HangupCauseCode: 58.
- Codec standardization: Logs indicated the internal codec was attempting to switch to GSM, causing transcoding with the external line (ulaw). Therefore,
ulawwas set as the only allowed codec insip.conf. - Delayed Snoop creation timing: Snoop creation occurred immediately when the external line went
Up(answered), so we introduced a 1500ms delay.
Desired Outcome
We want to maintain calls from internal to external lines without triggering forced hangups.
I have attached the source code for the ARI client application and the text file containing the CLI logs. I would appreciate it if you could review them.
cli_log.txt (11.4 KB)
ari_client.zip (8.7 KB)