Asterisk 19.3.1, PJSIP, Docker on MacOS - No Audio

Hi,

I’m running a dockerised version of Asterisk 19.3.1 using PJSIP Channel Driver on a MacOS host machine and I’m trying to make a call to it using Zoiper5 as the soft phone application. The registration process works well however the audio is not really.

Problem #1: Sometimes I hear the audio file played back by the Playback application through my audio output device but more often not when dialling 100 through the soft phone app.

Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 19.3.1 currently running on ad896dda5165 (pid = 8)
    -- Executing [100@incoming:1] Answer("PJSIP/zoiper-00000001", "") in new stack
       > 0x7f665801f020 -- Strict RTP learning after remote address set to: 37.156.73.177:25864
    -- Executing [100@incoming:2] Wait("PJSIP/zoiper-00000001", "1") in new stack
    -- Executing [100@incoming:3] Playback("PJSIP/zoiper-00000001", "hello-world") in new stack
    -- <PJSIP/zoiper-00000001> Playing 'hello-world.ulaw' (language 'en')
    -- Executing [100@incoming:4] Hangup("PJSIP/zoiper-00000001", "") in new stack
  == Spawn extension (incoming, 100, 4) exited non-zero on 'PJSIP/zoiper-00000001'

Problem #2: The recording ends instantly when dialling 200 and produces an empty wav file with 44 bytes. The same happens if I introduce a Wait before hanging up.

Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 19.3.1 currently running on ad896dda5165 (pid = 8)
    -- Executing [200@incoming:1] Answer("PJSIP/zoiper-00000000", "") in new stack
       > 0x7f6658020fe0 -- Strict RTP learning after remote address set to: 37.156.73.177:28799
    -- Executing [200@incoming:2] NoOp("PJSIP/zoiper-00000000", "Recording with "MixMonitor"") in new stack
    -- Executing [200@incoming:3] NoOp("PJSIP/zoiper-00000000", "UNIQUEID: 1649443317.0") in new stack
    -- Executing [200@incoming:4] Set("PJSIP/zoiper-00000000", "FILENAME=1649443317.0_20220408-184158.wav") in new stack
    -- Executing [200@incoming:5] MixMonitor("PJSIP/zoiper-00000000", "1649443317.0_20220408-184158.wav,W(4)") in new stack
  == Begin MixMonitor Recording PJSIP/zoiper-00000000
    -- Executing [200@incoming:6] NoOp("PJSIP/zoiper-00000000", "Recording location: /var/spool/asterisk/monitor/1649443317.0_20220408-184158.wav") in new stack
    -- Executing [200@incoming:7] Hangup("PJSIP/zoiper-00000000", "") in new stack
  == Spawn extension (incoming, 200, 7) exited non-zero on 'PJSIP/zoiper-00000000'
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/zoiper-00000000
Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 19.3.1 currently running on ad896dda5165 (pid = 8)
    -- Executing [200@incoming:1] Answer("PJSIP/zoiper-00000000", "") in new stack
       > 0x7f0c54020fc0 -- Strict RTP learning after remote address set to: 37.156.73.177:26193
    -- Executing [200@incoming:2] NoOp("PJSIP/zoiper-00000000", "Recording with "MixMonitor"") in new stack
    -- Executing [200@incoming:3] NoOp("PJSIP/zoiper-00000000", "UNIQUEID: 1649443180.0") in new stack
    -- Executing [200@incoming:4] Set("PJSIP/zoiper-00000000", "FILENAME=1649443180.0_20220408-183940.wav") in new stack
    -- Executing [200@incoming:5] MixMonitor("PJSIP/zoiper-00000000", "1649443180.0_20220408-183940.wav,W(4)") in new stack
    -- Executing [200@incoming:6] NoOp("PJSIP/zoiper-00000000", "Recording location: /var/spool/asterisk/monitor/1649443180.0_20220408-183940.wav") in new stack
    -- Executing [200@incoming:7] Wait("PJSIP/zoiper-00000000", "86400") in new stack
  == Begin MixMonitor Recording PJSIP/zoiper-00000000
  == Spawn extension (incoming, 200, 7) exited non-zero on 'PJSIP/zoiper-00000000'
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/zoiper-00000000

My related configuration and setup is described below.

rtp.conf

[general]
rtpstart=10000
rtpend=10099
[ice_host_candidates]

pjsip.conf

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[zoiper]
type=endpoint
context=incoming
disallow=all
allow=ulaw
auth=zoiper_auth
aors=zoiper

[zoiper_auth]
type=auth
auth_type=userpass
password=1234
username=zoiper

[zoiper]
type=aor
max_contacts=1

extensions.conf

[globals]
MONITOR_DIR=/var/spool/asterisk/monitor
RECORDING_DIR=/var/spool/asterisk/recording

[incoming]
exten => 100,1,Answer()
same => n,Wait(1)
same => n,Playback(hello-world)
same => n,Hangup()

exten => 200,1,Answer()
same => n,NoOp(Recording with "MixMonitor")
same => n,NoOp(UNIQUEID: ${UNIQUEID})
same => n,Set(FILENAME=${UNIQUEID}_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}.wav)
same => n,MixMonitor(${FILENAME},W(4))
same => n,NoOp(Recording location: ${MONITOR_DIR}/${FILENAME})
;same => n,Wait(86400)
same => n,Hangup()

exten => 300,1,Answer()
same => n,NoOp(Recording with "Record")
same => n,NoOp(UNIQUEID: ${UNIQUEID})
same => n,Set(FILENAME=${UNIQUEID}_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}.wav)
same => n,Record(${FILENAME},,,qk)
same => n,NoOp(Recording location: ${RECORDING_DIR}/${FILENAME})
same => n,Hangup()

Docker

CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS          PORTS                                                          NAMES
ad896dda5165   asterisk   "/bin/sh -c ./start.…"   23 minutes ago   Up 23 minutes   0.0.0.0:5060->5060/udp, 0.0.0.0:10000-10099->10000-10099/udp   asterisk

Network
Docker container IP: 172.17.0.2
Docker container Gateway: 172.17.0.1
Docker subnet: 192.168.65.0/24
Host IP from container: 192.168.65.2
Public IP: 37.156.73.177

Can you please advise on what’s wrong with my current setup and what do I need to change in order to resolve my RTP issues and make the audio working once and for all in both cases?

Thanks in advance!

If you record a call where you immediately hang up, the recording will be empty!

Are you sure you didn’t mean to use Record()?

Also, please take the logs from the log files, not the screen, as the former contain more time stamps.

Please explain where the “audio output device” fits in, and how it differs from the “soft phone app”.

which type of Container Network Model are you using
as you probably need to set

;local_net=0.0.0.0/255.255.255.255 or ;local_net=192.168.65.0/24
;external_media_address=37.156.73.177
;external_signaling_address=37.156.73.177

try look at what incoming ip traffic is coming from

Hi @david551,

Thanks for your reply!

Didn’t know that MixMonitor requires to have a preceding Wait application before the Hangup in order to get something recorded. Nevertheless, I tried that as well but didn’t work. After a while when I press the hang up button in the soft phone app it exists with a non-zero error code according to the logs. The related recording file is still empty.

I’ve slightly changed the dialplans compared to what I posted earlier as you can see in the logs but nothing groundbreaking apart from introducing that Wait.

[Apr 12 11:48:54] VERBOSE[37] res_pjsip/pjsip_configuration.c: Endpoint zoiper is now Reachable
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:1] Answer("PJSIP/zoiper-00000001", "") in new stack
[Apr 12 11:49:27] VERBOSE[36] res_rtp_asterisk.c: 0x7efcfc0102d0 -- Strict RTP learning after remote address set to: 217.38.56.228:61189
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:2] NoOp("PJSIP/zoiper-00000001", "Audio recording with MixMonitor - mixed file") in new stack
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:3] NoOp("PJSIP/zoiper-00000001", "UNIQUEID: 1649764167.1") in new stack
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:4] Set("PJSIP/zoiper-00000001", "FILENAME=1649764167.1_20220412-114927.wav") in new stack
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:5] MixMonitor("PJSIP/zoiper-00000001", "1649764167.1_20220412-114927.wav,W(4)") in new stack
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:6] NoOp("PJSIP/zoiper-00000001", "Audio recording will be available at: /var/spool/asterisk/monitor/1649764167.1_20220412-114927.wav") in new stack
[Apr 12 11:49:27] VERBOSE[106][C-00000002] pbx.c: Executing [200@incoming:7] Wait("PJSIP/zoiper-00000001", "5000") in new stack
[Apr 12 11:49:27] VERBOSE[107][C-00000002] app_mixmonitor.c: Begin MixMonitor Recording PJSIP/zoiper-00000001
[Apr 12 11:49:43] VERBOSE[102][C-00000001] pbx.c: Spawn extension (incoming, 200, 7) exited non-zero on 'PJSIP/zoiper-00000000'
[Apr 12 11:49:43] VERBOSE[103][C-00000001] app_mixmonitor.c: MixMonitor close filestream (mixed)
[Apr 12 11:49:43] VERBOSE[103][C-00000001] app_mixmonitor.c: End MixMonitor Recording PJSIP/zoiper-00000000

I’ve been playing around with Record as well but that hangs for about a minute and does not produce anything in the end after I press hang up in the soft phone app:

Apr 12 11:55:54] VERBOSE[112][C-00000003] pbx.c: Executing [300@incoming:1] Answer("PJSIP/zoiper-00000002", "") in new stack
[Apr 12 11:55:54] VERBOSE[36] res_rtp_asterisk.c: 0x7efcfc01f7c0 -- Strict RTP learning after remote address set to: 217.38.56.228:55461
[Apr 12 11:55:54] VERBOSE[112][C-00000003] pbx.c: Executing [300@incoming:2] NoOp("PJSIP/zoiper-00000002", "Audio recording with Record") in new stack
[Apr 12 11:55:54] VERBOSE[112][C-00000003] pbx.c: Executing [300@incoming:3] NoOp("PJSIP/zoiper-00000002", "UNIQUEID: 1649764554.4") in new stack
[Apr 12 11:55:54] VERBOSE[112][C-00000003] pbx.c: Executing [300@incoming:4] Set("PJSIP/zoiper-00000002", "FILENAME=1649764554.4_20220412-115554.wav") in new stack
[Apr 12 11:55:54] VERBOSE[112][C-00000003] pbx.c: Executing [300@incoming:5] Record("PJSIP/zoiper-00000002", "1649764554.4_20220412-115554.wav,,,qk") in new stack
[Apr 12 11:56:58] VERBOSE[112][C-00000003] pbx.c: Spawn extension (incoming, 300, 5) exited non-zero on 'PJSIP/zoiper-00000002'

Can you please shed some light on in what use cases should I use MixMonitor and Record? Eventually I would like to record both participants of a given call, ideally in separate files if possible.

As per your request I’ve turned on full logging and grabbed the stuff from there to have a clearer picture on what’s going on.

Audio output device - whichever device is available on my Mac and set as output device in the soft phone app (built-in speakers / headphones)

You are not using MixMonitor for its intended purpose. The expectation is that there will be an actual phone conversation, before the Hangup.

You still haven’t used the log files, which are important where timing is of the nature of the problem.

Are you sure that Asterisk is receiving any media to record?

Hi @TheMark,

Thanks for replying.

I’m using bridge as the network driver which is the default anyway. Mode host does not work on a Mac that I’m using.

I’ve tried your suggestions using whatever public IP I had at the time of testing as the external addresses and almost all combinations of local_net (either or both of them specified as you mentioned) but still no luck.

So my goal would be, at least for this very basic test scenario, that when I dial the given extension (200) from my soft phone app then Asterisk answers and whatever I say to the configured input device of the soft phone app that gets recorded through Asterisk until Asterisk or the client hangs up. Could this work based on my dialplan?

I’ve thought you meant the full.log file which can be configured in /etc/asterisk/logger.conf. If it wasn’t that then what did you mean instead precisely? How can I turned that on or where should I get those files from? Sorry for the basic questions but I’m just scratching the surface.

Regarding whether Asterisk receives any media, I’m not sure. My assumption is not, hence I’m facing some of these issues. How can I verify that?

You’d normally use Record() for that. It’s synchronous, so doesn’t need the Wait However, MixMonitor should still have recorded something if media is arriving.

I mean /var/log/asterisk/full, after enabling it, rather than scraping the screen.

You should be logging the protocol (pjsip set logger on) and using RTP debugging, to determine that.

just for testing try use the Echo aplication

[incoming]
exten => 400,1,Answer()
same => n,Playback(beep) ;may fix statefull fw/route issues
same => n,Echo()

exten => 401,1,Answer()
same => n,Echo()

also can you try both on your mac and inside docker see where the RTP is being send to
to what IP is your softphone sending from/to and the same for asterisk

I think you meant Playback

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.