ChanSpy whisper problem

Hello everybody,
I am currently using asterisk as a “pass-thru” SIP gateway.
Phones register on a CISCO based system and call out via their respective PBX.
The PBX routes the call thru asterisk, asterisk routes it back to another PBX.
This is done in order to record calls that pass through the asterisk servers.

In this scenario, I recently wanted to integrate ChanSpy (specifically with whisper and barge functions).

In fact, the ChanSpy function works pretty well. The Spier can hear both parties.
Unfortunately thou, whisper and barge do not work the way they should.

Specifically, whisper does nothing (no parties can hear the Spier).
Barge works (imho, half way) but only the called party can hear the spier. The spied user cannot.

This is my extensions.conf (the relevant)

exten => _[*#0-9]!,1,NoOp()
exten => _[*#0-9]!,n,Set(xunique=${PJSIP_HEADER(read,x-unique)})
exten => _[*#0-9]!,n,Set(xprefix=${PJSIP_HEADER(read,x-asterisk-prefix)})
exten => _[*#0-9]!,n,Set(username=${PJSIP_HEADER(read,x-username)})
exten => _[*#0-9]!,n,Set(userid=${PJSIP_HEADER(read,x-userid)})
exten => _[*#0-9]!,n,GotoIf($["${userid}" != ""]?setspygroup:nospygroup)
exten => _[*#0-9]!,n(setspygroup),Set(SPYGROUP=${userid})
exten => _[*#0-9]!,n(nospygroup),NoOp()
exten => _[*#0-9]!,n,Set(CALLEDNUM=${EXTEN})
exten => _[*#0-9]!,n,Log(WARNING, Call ${xunique} started from ${CALLERID(num)} (${username} spyGroup ${SPYGROUP}) to ${EXTEN} (${xprefix}${EXTEN}) recorded as /var/records/${xunique}.wav)
exten => _[*#0-9]!,n,MixMonitor(/var/records/${xunique}.wav,abW(4))
exten => _[*#0-9]!,n,Dial(PJSIP/vg4/sip:${xprefix}${EXTEN}@MY-NEXT-HOP,60,gXwW)
exten => _[*#0-9]!,n,StopMixMonitor()
exten => _[*#0-9]!,n,Hangup()
exten => h,1,NoOp(CALLEDNUM=${CALLEDNUM})
exten => h,n,StopMixMonitor()
exten => h,n,Log(WARNING, Call ${xunique} closed from ${CALLERID(num)} to ${CALLEDNUM} (${xprefix}${CALLEDNUM}) with status ${DIALSTATUS} (${HANGUPCAUSE}) recorded as /var/records/${xunique}.wav)

exten => _88XXXX,1,NoOp()
exten => _88XXXX,n,Set(SPY=${EXTEN:2})
exten => _88XXXX,n,ChanSpy(,wdg(${SPY})v(4)q)
exten => _88XXXX,n,UserEvent(ChanSpy,User ${CALLBACKNUM} spied on ${SPY})```

So, just to make clear, the flow is:
phase 1

  1. Agent dials a number
  2. Cisco PBX routes the call to Asterisk
  3. Asterisk records the call and routes it to “MY-NEXT-HOP”
    This works flawlessy.

phase 2

  1. Supervisor dials 881234 (where 1234 is the agent userid)
  2. ChanSpy is activated (Supervisor CAN hear both the agent and the called party)
  3. Supervisor presses “4”, he can hear both parties.
  4. Supervisor presses “5” and talks, noone can hear him
  5. Supervisor presses “6” and talks, called party can hear him, but calling party does not hear him.

All looks normal from the logs:

  == Spying on channel PJSIP/anonymous-00000003
    -- Attaching spy channel PJSIP/anonymous-00000005 to PJSIP/anonymous-00000003
    -- Attaching spy channel PJSIP/anonymous-00000005 to PJSIP/anonymous-00000003
       > 0x7fe73400a7a0 -- Strict RTP learning complete - Locking on source address xx.xx.xx.xx:20358
    -- Attaching spy channel PJSIP/anonymous-00000005 to PJSIP/vg4-00000004
  == Done Spying on channel PJSIP/anonymous-00000003

I’ve tried disabling MixMonitor - no effect.
I’ve tried with asterisk 16.0.1, 16.10.0 and 17.4.0 - same issues.

Anything I am missing or doing wrong?

Any idea to point me in the right direction?

Thank for your time and help.


in the process of deep testing the issue I switched to SIP from PJSIP.
I don’t think this makes a big difference, but while testing I realized that whisper actually works.
In fact the whole point is that che SPIER voice in injected in the SPIED phone only when the third party is actually speaking.

This is a big issue, with modern codecs and configuration all running some sort of VAD.

Is there a way to bypass this?

I am trying to generate some comfort noise on the outgoing PBX… with little luck so far…

Ideas welcome

No, it’s a known issue[1] and due to a fundamental way that things work. Asterisk in general requires a constant stream of audio. Some things have been made to tolerate the lack of one, but not everything.


Thank you jcolp,
before I get mad at enabling comfort noise without resolving the issue…
is it also a matter of noise level or just a matter of audio frames being sent and received?

In my scenario, do you think it would be enough to have comfort noise enabled as per this “graph”?

[phone] <--vad--> [pbx 1] <--vad--> [asterisk] <--no vad--> [pbx 2] <--no vad--> [isdn]

If that would work (and if I manage to enable that…) it would not impact much my networking, as from [asterisk] to [isdn] is all local to my network, while only [phone] and [pbx 1] are remote.

Thank you again

I don’t know what “comfort noise” means within this context because it can mean different things. Whisper, however, requires a flow of audio frames - it doesn’t care about the noise level in them.

Thank you so far.
I would consider this topic closed.
Maybe it would pay to make this information clear and widely available for future references, as it took me (and possibly others in the future) quite some effort to understand what was going on…