# ChanSpy problem

**URL:** <https://community.asterisk.org/t/chanspy-problem/30095>\
**Category:** Asterisk Support\
**Created:** [December 26, 2009, 9:53am UTC](https://community.asterisk.org/t/chanspy-problem/30095 "2009-12-26T09:53:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [December 26, 2009, 9:53am UTC](https://community.asterisk.org/t/chanspy-problem/30095/1 "2009-12-26T09:53:42Z")

</div>

Hi, ChanSpy doesn’t work on my system. I hear just one channel at a time (the caller or the calee).

About the system:

[code]\>uname -a  
Linux pbx.provider.tld 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux

> cat /etc/redhat-release  
> CentOS release 5.4 (Final)

> asterisk -V  
> Asterisk 1.4.26.3[/code]

Elastix 1.6-13  
FreePBX 2.6.0.0

One of the extensions:

`[152]
deny=0.0.0.0/0.0.0.0
secret=XXXXXX
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
type=friend
nat=yes
port=5060
qualify=yes
callgroup=
pickupgroup=
dial=SIP/152
accountcode=
mailbox=152@device
permit=0.0.0.0/0.0.0.0
callerid=device <152>
call-limit=50`

The ChanSpy:

`[app-chanspy]
include => app-chanspy-custom
exten => 555,1,Macro(user-callerid,)
exten => 555,n,Answer
exten => 555,n,Wait(1)
exten => 555,n,ChanSpy()
exten => 555,n,Hangup`

Calling to ChanSpy gives:

```auto
  == Spying on channel SIP/152-09891b98
```

During an active call i have:

`pbx*CLI> core show channels
Channel Location State Application(Data)             
SIP/155-b6c081b0 555@from-internal:4 Up ChanSpy()                     
SIP/152-09891b98 (None) Up AppDial((Outgoing Line))      
SIP/provider-b6c004b s@macro-dial:7 Up Dial(SIP/145&SIP/146&SIP
3 active channels
2 active call`

Finaly i hear just one channel (SIP/152-09891b98 in this case). In Elastix 1.5.2 it was all ok: i heard the both channels.

---

<div class="post-metadata">

**Author:** ![bira\_more](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@bira\_more](https://community.asterisk.org/u/bira_more)\
**Post date:** [December 26, 2009, 10:32pm UTC](https://community.asterisk.org/t/chanspy-problem/30095/2 "2009-12-26T22:32:45Z")

</div>

I had to play some staff to both sides simultaneously, and I played what I want to play to every channel.  
I suppose same is for listening.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [December 30, 2009, 8:09am UTC](https://community.asterisk.org/t/chanspy-problem/30095/3 "2009-12-30T08:09:34Z")

</div>

I think i’ve found the problem: [issues.asterisk.org/view.php?id=16167](https://issues.asterisk.org/view.php?id=16167) . But is this actual for my version of asterisk ?

---

<div class="post-metadata">

**Author:** ![bira\_more](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@bira\_more](https://community.asterisk.org/u/bira_more)\
**Post date:** [December 30, 2009, 2:08pm UTC](https://community.asterisk.org/t/chanspy-problem/30095/4 "2009-12-30T14:08:09Z")

</div>

Simplest way is to modify code a little rebuild asterisk and check what happens:

```auto
//if (ast_test_flag(chan, OPTION_READONLY)) {
        /* Option 'o' was set, so don't mix channel audio */
// f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, AST_FORMAT_SLINEAR);
// } else {
        f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
// }
```

4 comments and you will see what happens.
