Understanding MASTER_CHANNEL function

I don’t understand how MASTER_CHANNEL works. If I create this simple dialplan:

[context-test]
exten => _[*0-9]!,1,Dial(PJSIP/1002,30,U(sub-test))
same => n,Hangup()

[sub-test]
exten => s,1,NoOP(channel name is '${CHANNEL(name)}' with state '${CHANNEL(state)}')
same => n,NoOP(master channel name is '${MASTER_CHANNEL(name)}' with state '${MASTER_CHANNEL(state)}' and caller id ${MASTER_CHANNEL(CALLERID)})
same => n,Return()

The result is:

-- Executing [1002@context-test:1] Dial("PJSIP/1001-00000000", "PJSIP/1002,30,U(sub-test)") in new stack
    -- Called PJSIP/1002
    -- PJSIP/1002-00000001 is ringing
    -- PJSIP/1002-00000001 is ringing
    -- PJSIP/1002-00000001 answered PJSIP/1001-00000000
    -- PJSIP/1002-00000001 Internal Gosub(sub-test,s,1) start
    -- Executing [s@sub-test:1] NoOp("PJSIP/1002-00000001", "channel name is 'PJSIP/1002-00000001' with state 'Up'") in new stack
    -- Executing [s@sub-test:2] NoOp("PJSIP/1002-00000001", "master channel name is '' with state '' and caller id ") in new stack
    -- Executing [s@sub-test:3] Return("PJSIP/1002-00000001", "") in new stack
  == Spawn extension (context-test, , 1) exited non-zero on 'PJSIP/1002-00000001'
    -- PJSIP/1002-00000001 Internal Gosub(sub-test,s,1) complete GOSUB_RETVAL=
    -- Channel PJSIP/1002-00000001 joined 'simple_bridge' basic-bridge <04219b54-0a05-4e2b-a3d7-0a51fb4602dd>
    -- Channel PJSIP/1001-00000000 joined 'simple_bridge' basic-bridge <04219b54-0a05-4e2b-a3d7-0a51fb4602dd>
    -- Channel PJSIP/1002-00000001 left 'native_rtp' basic-bridge <04219b54-0a05-4e2b-a3d7-0a51fb4602dd>
    -- Channel PJSIP/1001-00000000 left 'native_rtp' basic-bridge <04219b54-0a05-4e2b-a3d7-0a51fb4602dd>
  == Spawn extension (context-test, 1002, 1) exited non-zero on 'PJSIP/1001-00000000'

As you can see the values for MASTER_CHANNEL are empty whereas I was expecting to see some values. I’m a misunderstanding how this function works?

Please edit your posting to markup dialplan and logs as preformatted text, otherwise they appear corrupted in the forum.

As I read the documentation, the parameter needs to be a channel variable name, although it might possibly evaluate functions, as well. You haven’t set name.

In this context, I would set an inheritable variable to the current channel name, before calling Dial.

OK I managed to sort this one out. The working dialplan now looks like this:

[context-test]
exten => _[*0-9]!,1,NoOP()
same => n,Dial(PJSIP/1002,30,U(sub-test))
same => n,Hangup()

[sub-test]
exten => s,1,NoOP(channel name is '${CHANNEL(name)}' with state '${CHANNEL(state)}')
same => n,NoOP(master channel name is '${MASTER_CHANNEL(CHANNEL(name))}' with state '${MASTER_CHANNEL(CHANNEL(state))}')
same => n,Return()
 -- Executing [1002@context-test:1] NoOp("PJSIP/1001-00000000", "") in new stack
    -- Executing [1002@context-test:2] Dial("PJSIP/1001-00000000", "PJSIP/1002,30,U(sub-test)") in new stack
    -- Called PJSIP/1002
    -- PJSIP/1002-00000001 is ringing
    -- PJSIP/1002-00000001 is ringing
    -- PJSIP/1002-00000001 answered PJSIP/1001-00000000
    -- PJSIP/1002-00000001 Internal Gosub(sub-test,s,1) start
    -- Executing [s@sub-test:1] NoOp("PJSIP/1002-00000001", "channel name is 'PJSIP/1002-00000001' with state 'Up'") in new stack
    -- Executing [s@sub-test:2] NoOp("PJSIP/1002-00000001", "master channel name is 'PJSIP/1001-00000000' with state 'Ring'") in new stack
    -- Executing [s@sub-test:3] Return("PJSIP/1002-00000001", "") in new stack
  == Spawn extension (context-test, , 1) exited non-zero on 'PJSIP/1002-00000001'
    -- PJSIP/1002-00000001 Internal Gosub(sub-test,s,1) complete GOSUB_RETVAL=
    -- Channel PJSIP/1002-00000001 joined 'simple_bridge' basic-bridge <0879b9b0-5131-4b6c-a68d-263149e5e6e3>
    -- Channel PJSIP/1001-00000000 joined 'simple_bridge' basic-bridge <0879b9b0-5131-4b6c-a68d-263149e5e6e3>
    -- Channel PJSIP/1002-00000001 left 'native_rtp' basic-bridge <0879b9b0-5131-4b6c-a68d-263149e5e6e3>
    -- Channel PJSIP/1001-00000000 left 'native_rtp' basic-bridge <0879b9b0-5131-4b6c-a68d-263149e5e6e3>
  == Spawn extension (context-test, 1002, 2) exited non-zero on 'PJSIP/1001-00000000'
1 Like

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