[Home]

Summary:ASTERISK-15450: Chanspy application does not exit when user hangs up
Reporter:Mark Murawski (kobaz)Labels:
Date Opened:2010-01-17 13:06:05.000-0600Date Closed:2011-06-07 14:07:55
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Applications/app_chanspy
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:1.6.0 svn tr

IAX device dials 267@services, ChanSpy executes... IAX device hangs up... chanspy is still running

extend context services {
 267 => {
   Answer();
   ChanList(SIP/213);
   Set(encchannel=${BASE64_ENCODE(${CHANLIST_RESULT})});
   goto connectToChannel, ${encchannel}, 1;
 }
}

context connectToChannel {
 h => {
   Hangup();
 }

 _.! => {
   Set(spy=${BASE64_DECODE(${EXTEN})});
   Answer();
   ChanSpy(${spy},qw);
 }
}


   -- Executing [267@trunkhandler_from-branch:1] Answer("IAX2/branch-9556", "") in new stack
   -- Executing [267@trunkhandler_from-branch:2] ChanList("IAX2/branch-9556", "SIP/213") in new stack
   -- Executing [267@trunkhandler_from-branch:3] Set("IAX2/branch-9556", "encchannel=U0lQLzIxMy0wMDAwMDAwMA==") in new stack
   -- Executing [267@trunkhandler_from-branch:4] Goto("IAX2/branch-9556", "connectToChannel,U0lQLzIxMy0wMDAwMDAwMA==,1") in new stack
   -- Goto (connectToChannel,U0lQLzIxMy0wMDAwMDAwMA==,1)
   -- Executing [U0lQLzIxMy0wMDAwMDAwMA==@connectToChannel:1] Set("IAX2/branch-9556", "spy=SIP/213-00000000") in new stack
   -- Executing [U0lQLzIxMy0wMDAwMDAwMA==@connectToChannel:2] Answer("IAX2/branch-9556", "") in new stack
   -- Executing [U0lQLzIxMy0wMDAwMDAwMA==@connectToChannel:3] ChanSpy("IAX2/branch-9556", "SIP/213-00000000,qw") in new stack
 == Spying on channel SIP/213-00000000
[Jan 17 13:54:44] NOTICE[8329]: app_chanspy.c:245 start_spying: Attaching IAX2/branch-9556 to SIP/213-00000000
[Jan 17 13:54:44] NOTICE[8329]: app_chanspy.c:245 start_spying: Attaching IAX2/branch-9556 to SIP/213-00000000

--- IAX2/branch-9556 hangs up here ---

> core show channels
Channel              Location             State   Application(Data)
IAX2/branch-9556     U0lQLzIxMy0wMDAwMDAw Up      ChanSpy(SIP/213-00000000,qw)
SIP/213-00000000     s@dialExten:1        Up      AppDial((Outgoing Line))
IAX2/branch-3772     s@dialExten:5        Up      Dial(SIP/213)


I'm not good enough with the code yet to see why it's happening... but I see where it's happening.

Line 416 of app_chanspy.c

414:        if (ast_test_flag(flags, OPTION_WHISPER)) {
415:                ast_audiohook_lock(&csth.whisper_audiohook);
416:                ast_audiohook_detach(&csth.whisper_audiohook); // lockup
417:                ast_audiohook_unlock(&csth.whisper_audiohook);
418:                ast_audiohook_destroy(&csth.whisper_audiohook);
419:        }

If the spyee channel hangs up, ast_audiohook_detach() will finish, and ChanSpy will end.

This only happens when there is no audio being generated.
Comments:By: Mark Murawski (kobaz) 2010-01-17 13:08:06.000-0600

Well... actually, the why is related to https://issues.asterisk.org/view.php?id=16524.

But... we have no control over whether there is audio generated by a remote peer.  The Wait() generate silence fixes this only locally.

By: Leif Madsen (lmadsen) 2010-01-18 10:47:18.000-0600

OK thanks for pointing that issue out, I was thinking it sounded an awful lot like another issue recently resolved, but perhaps there is more to it in this scenario.

By: Jeff Peeler (jpeeler) 2010-07-28 18:04:46

Kobaz - this is just a reminder for you to repost an example of reproducing without using the non supported ChanList functionality.

By: Mark Murawski (kobaz) 2010-07-29 09:30:52

Two tests

 '_267' =>         1. Answer()                                   [pbx_ael]
                   2. ChanSpy(SIP/2618)                          [pbx_ael]

 '_267' =>         1. Answer()                                   [pbx_ael]
                   2. ChanSpy(SIP/2618,b)                        [pbx_ael]


202 spys on 2618... same result when using b or no b.

This seems more like a feature request than a bug.  ChanSpy() seems to loop around indefinitely waiting for callers on the specified device.  Maybe there needs to be a new option 'h' or similar, that would end chanspy if there is nothing to spy on.


   -- Executing [267@trunkhandler_from-branch:2] ChanSpy("SIP/202-00000003", "SIP/2618,b") in new stack
   -- <SIP/202-00000003> Playing 'beep.ulaw' (language 'en')
   -- <SIP/202-00000003> Playing 'spy-sip.ulaw' (language 'en')
   -- <SIP/202-00000003> Playing 'digits/2.ulaw' (language 'en')
   -- <SIP/202-00000003> Playing 'digits/6.ulaw' (language 'en')
   -- <SIP/202-00000003> Playing 'digits/1.ulaw' (language 'en')
   -- <SIP/202-00000003> Playing 'digits/8.ulaw' (language 'en')
 == Spying on channel SIP/2618-00000002
[Jul 29 10:24:44] NOTICE[19889]: app_chanspy.c:245 start_spying: Attaching SIP/202-00000003 to SIP/2618-00000002
   -- Executing [h@dialOut:1] Set("SIP/2618-00000002", "ARGS="module=CallRouter,action=DialHangup"") in new stack
   -- Executing [h@dialOut:2] AGI("SIP/2618-00000002", "agi://127.0.0.1:2000") in new stack
   -- <SIP/2618-00000002>AGI Script agi://127.0.0.1:2000 completed, returning 0
   -- Hungup 'IAX2/tipton-local-11035'
   -- AGI Script Executing Application: (Hangup) Options: ()
   -- <SIP/2618-00000002>AGI Script agi://127.0.0.1:2000 completed, returning 0
   -- Executing [s@dialOut:8] Return("SIP/2618-00000002", "") in new stack
   -- Auto fallthrough, channel 'SIP/2618-00000002' status is 'ANSWER'
 == Done Spying on channel SIP/2618-00000002
   -- <SIP/202-00000003> Playing 'beep.ulaw' (language 'en')

core show channels

Channel              Location             State   Application(Data)
SIP/202-00000003     267@trunkhandler_fro Up      ChanSpy(SIP/2618,b)

1 active channel1*CLI>

By: Jeff Peeler (jpeeler) 2010-08-02 17:38:15

Isn't this what the 'S' option does?

By: Mark Murawski (kobaz) 2010-08-02 17:46:44

Is that in trunk?  It's not available in 1.6.0 or 1.6.2

By: Jeff Peeler (jpeeler) 2010-08-02 17:49:29

Trunk and 1.8. I'm going to close this.