How to get Spy Extension working.

I’ve been trying to get the “Spy on Extension” feature working. Is there a trick to it? I dial *55, it then asks for an extension. Sometimes it works as expected, and I’ll be able to listen to the conversation. MOST of the time though, it will just hang up. I’ve also had it ask for a password, but now I can’t seem to get that to happen again.

I’ve tried it while the extension was on a call, as well as before the ext placed a call. I’ve also verified that the “Block Spy Me” feature was turned off for the relevant extensions.

Any help is appreciated.

Has anyone tried this feature before? It seems to work once about every five to ten times I try it… and I can’t seem to figure out what’s different between my attempts.

Have you checked the Asterisk logs through the Asterisk CLI?

I’ve tailed /var/log/asterisk/full with extension 401 trying to spy on 604 and got the following:

[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-local-dialing:5] Return("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@cos-all:12] GotoIf("PJSIP/401-00000faf", "0?end-call") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@cos-all:13] Goto("PJSIP/401-00000faf", "cos-all-post,*55,1") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx_builtins.c: Goto (cos-all-post,*55,1)
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [*55@cos-all-post:1] NoOp("PJSIP/401-00000faf", "Spy on Extension") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [*55@cos-all-post:2] Set("PJSIP/401-00000faf", "CHANNEL(hangup_handler_push)=local-call-hangup,s,1") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [*55@cos-all-post:3] Gosub("PJSIP/401-00000faf", "sub-spy-ext,s,1") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-spy-ext:1] NoOp("PJSIP/401-00000faf", "FEATURE: SPY SPECIFIED EXTENSION") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-spy-ext:2] Gosub("PJSIP/401-00000faf", "sub-extension-spy,s,1") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:1] Set("PJSIP/401-00000faf", "SPY_OPTIONS=qS") in new stack
[2023-09-13 11:26:44] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:2] Read("PJSIP/401-00000faf", "EXTENSION_NUMBER,vpbx/vital-spy-extension-number") in new stack
[2023-09-13 11:26:45] VERBOSE[3663386][C-00000b06] file.c: <PJSIP/401-00000faf> Playing 'vpbx/vital-spy-extension-number.ulaw' (language 'en')
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] app_read.c: User entered '604'
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:3] GotoIf("PJSIP/401-00000faf", "0?read_ext") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:4] Set("PJSIP/401-00000faf", "EXTENSION_DIAL=PJSIP/604&PJSIP/604vitxi&PJSIP/604_app") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:5] GotoIf("PJSIP/401-00000faf", "0?read_ext") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:6] GotoIf("PJSIP/401-00000faf", "0?:skip_pwd") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx_builtins.c: Goto (sub-extension-spy,s,10)
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:10] NoOp("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:11] Set("PJSIP/401-00000faf", "DEVICE_TO_SPY=") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:12] Set("PJSIP/401-00000faf", "COUNTER=1") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:13] Set("PJSIP/401-00000faf", "CURRENT_DEVICE=PJSIP/604") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:14] While("PJSIP/401-00000faf", "1") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:15] Set("PJSIP/401-00000faf", "DEVICE_STATUS=BUSY") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:16] GotoIf("PJSIP/401-00000faf", "0?:next") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx_builtins.c: Goto (sub-extension-spy,s,20)
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:20] Set("PJSIP/401-00000faf", "COUNTER=2") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:21] Set("PJSIP/401-00000faf", "CURRENT_DEVICE=PJSIP/604vitxi") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:22] EndWhile("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:14] While("PJSIP/401-00000faf", "1") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:15] Set("PJSIP/401-00000faf", "DEVICE_STATUS=UNAVAILABLE") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:16] GotoIf("PJSIP/401-00000faf", "0?:next") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx_builtins.c: Goto (sub-extension-spy,s,20)
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:20] Set("PJSIP/401-00000faf", "COUNTER=3") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:21] Set("PJSIP/401-00000faf", "CURRENT_DEVICE=PJSIP/604_app") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:22] EndWhile("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:14] While("PJSIP/401-00000faf", "1") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:15] Set("PJSIP/401-00000faf", "DEVICE_STATUS=UNAVAILABLE") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:16] GotoIf("PJSIP/401-00000faf", "0?:next") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx_builtins.c: Goto (sub-extension-spy,s,20)
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:20] Set("PJSIP/401-00000faf", "COUNTER=4") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:21] Set("PJSIP/401-00000faf", "CURRENT_DEVICE=") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:22] EndWhile("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:14] While("PJSIP/401-00000faf", "0") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:23] GotoIf("PJSIP/401-00000faf", "1?h-call") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx_builtins.c: Goto (sub-extension-spy,s,25)
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@sub-extension-spy:25] Hangup("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Spawn extension (sub-extension-spy, s, 25) exited non-zero on 'PJSIP/401-00000faf'
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] app_stack.c: PJSIP/401-00000faf Internal Gosub(local-call-hangup,s,1) start
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@local-call-hangup:1] Verbose("PJSIP/401-00000faf", "0, Hangup Local Call") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] app_verbose.c:  Hangup Local Call
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@local-call-hangup:2] UserEvent("PJSIP/401-00000faf", ""EXTENSIONS_SUMMARY","Data: EXT_TO_FC,PJSIP/401,LOCAL"") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] pbx.c: Executing [s@local-call-hangup:3] Return("PJSIP/401-00000faf", "") in new stack
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] app_stack.c: Spawn extension (sub-extension-spy, s, 25) exited non-zero on 'PJSIP/401-00000faf'
[2023-09-13 11:26:52] VERBOSE[3663386][C-00000b06] app_stack.c: PJSIP/401-00000faf Internal Gosub(local-call-hangup,s,1) complete GOSUB_RETVAL=

The prompt after dialing *55 asked for an extension, I dialed 604 and then the call ended with no further response. 604 was on a call while I tried this, which I assume is the intended scenario?

Let us check the changelog!

I’ll keep you posted!

It is not working for you, because the feature expects the device to return “INUSE” instead of “BUSY.”

As a workaround, you can edit the file “/etc/asterisk/vitalpbx/extensions__20-baseplan.conf.” Search for the context “sub-extension-spy” and replace the line:

same => n,GotoIf($["${DEVICE_STATUS}"="INUSE"]?:next)

with

same => n,GotoIf($[$["${DEVICE_STATUS}"="INUSE"]|$["${DEVICE_STATUS}"="BUSY"]]?:next)

Awesome, that did get it working. Thanks!

Was that an error on my part? As far as I can tell, that’s the default setup? Will this be fixed in future releases?

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