In Asterisk version 18 has added the ability to transfer data over tcp for ExternalMedia channels
Asterisk 18 Channels REST API WIKI
Working through the UDP (encapsulation RTP) does not guarantee that all packages will be delivered.
There are indeed packet losses and now I am in the process of searching for minimizing these losses.
When using TCP (encapsulation audiosocket), there is no loss, but a small break in the connection leads to Asterisk failure
[22-12-11 07:56:09] WARNING[61] res_audiosocket.c: Connecting to '10.11.0.12:8911' failed for url '10.11.0.12:8911': Connection refused
[22-12-11 07:56:09] ERROR[61] res_audiosocket.c: Failed to connect to AudioSocket service
[22-12-11 07:56:09] WARNING[61] res_audiosocket.c: Connecting to '10.11.0.12:8907' failed for url '10.11.0.12:8907': Connection refused
[22-12-11 07:56:09] ERROR[61] res_audiosocket.c: Failed to connect to AudioSocket service
......more than 800 such errors
[22-12-11 08:04:34] WARNING[60][C-000003ec] channel.c: Unable to write to alert pipe on Local/992211@local_inbound-000003ea;1 (qlen = 0): Bad file descriptor!
[22-12-11 08:04:34] WARNING[60][C-000003ec] channel.c: Unable to write to alert pipe on Local/992211@local_inbound-000003ea;1 (qlen = 1): Bad file descriptor!
[22-12-11 08:04:34] WARNING[60][C-000003ec] channel.c: Unable to write to alert pipe on Local/992211@local_inbound-000003ea;1 (qlen = 2): Bad file descriptor!
[22-12-11 08:04:34] WARNING[60][C-000003ec] channel.c: Unable to write to alert pipe on Local/992211@local_inbound-000003ea;1 (qlen = 3): Bad file descriptor!
....more than 200 such errors
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 08:04:36] WARNING[6555][C-000003ec] alertpipe.c: read() failed: Bad file descriptor
....more than 85039 such errors
[22-12-11 10:08:49] WARNING[132927] res_audiosocket.c: Connecting to '10.11.0.12:8921' failed for url '10.11.0.12:8921': Connection refused
[22-12-11 10:08:49] ERROR[132927] res_audiosocket.c: Failed to connect to AudioSocket service
[22-12-11 10:08:49] WARNING[135273] res_audiosocket.c: Connecting to '10.11.0.12:8913' failed for url '10.11.0.12:8913': Connection refused
[22-12-11 10:08:49] ERROR[135273] res_audiosocket.c: Failed to connect to AudioSocket service
[22-12-11 10:08:50] WARNING[134302] res_audiosocket.c: Connecting to '10.11.0.12:8913' failed for url '10.11.0.12:8913': Connection refused
[22-12-11 10:08:50] ERROR[134302] res_audiosocket.c: Failed to connect to AudioSocket service
[22-12-11 10:08:50] WARNING[135458] bridge_channel.c: Weird. No frame from bridge for Local/992211@call_proxy_outbound-000054e1;1 to process?
[22-12-11 10:08:50] WARNING[135458] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 10:08:50] WARNING[135458] bridge_channel.c: Weird. No frame from bridge for Local/992211@call_proxy_outbound-000054e1;1 to process?
[22-12-11 10:08:50] WARNING[135458] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 10:08:50] WARNING[135458] bridge_channel.c: Weird. No frame from bridge for Local/992211@call_proxy_outbound-000054e1;1 to process?
[22-12-11 10:08:50] WARNING[135458] alertpipe.c: read() failed: Bad file descriptor
....more than 6698 such errors
[22-12-11 10:08:50] WARNING[135458] alertpipe.c: read() failed: Bad file descriptor
[22-12-11 10:08:50] WARNING[135458] alertpipe.c: read() failed: Bad file descriptor
....more than 22995 such errors
After such errors Asterisk becomes unavailable as a peer and it is impossible to create channels in it
[22-12-11 08:05:17] NOTICE[2900105] chan_sip.c: Peer 'calc5_1' is now UNREACHABLE! Last qualify: 1
After Asterisk freezes, netstat shows a high CLOSE_WAIT
netstat -an | awk '/tcp/ {print $6}' | sort | uniq -c
1736 CLOSE_WAIT
1062 ESTABLISHED
2 FIN_WAIT2
29 LISTEN
1308 TIME_WAIT
After restarting Asterisk, the number becomes less than 10
Maybe someone has faced the same problem? Which solutions are better to use? I would like to minimize UDP losses or keep Asterisk stable when TCP breaks