Skip to main content

Problem with the Background function

Posted by chris on Mon, 04/20/2009

Running MTE 6.0.1.71 with Asterisk 1.6.0.9

When I call the Background function from inside a macro, Asterisk seems to look back at the calling context instead of the context listed in the Background function. Unless, of course, you use an invalid context in the function call, then Asterisk tries to look at that one.

==================================

-- Executing [s@macro-background-test:1] Answer("IAX2/carolinanet_iax-8136", "") in new stack
-- Executing [s@macro-background-test:2] Wait("IAX2/carolinanet_iax-8136", "2") in new stack
-- Executing [s@macro-background-test:3] BackGround("IAX2/carolinanet_iax-8136", "press-2&en/silence/5,,,macro-background-test") in new stack
-- IAX2/carolinanet_iax-8136 Playing 'press-2.gsm' (language 'en')
-- IAX2/carolinanet_iax-8136 Playing 'en/silence/5.gsm' (language 'en')
[Apr 20 13:39:40] WARNING[10919]: pbx.c:3827 __ast_pbx_run: Invalid extension '2', but no rule 'i' in context 'from-outside-3365532707-tl-allhours-Chris'
-- Hungup 'IAX2/carolinanet_iax-8136'

This version should be correct. It calls an existing context, but Asterisk looks at the from-outside.... context for the extension.

==================================
-- Executing [s@macro-background-test:1] Answer("IAX2/carolinanet_iax-7326", "") in new stack
-- Executing [s@macro-background-test:2] Wait("IAX2/carolinanet_iax-7326", "2") in new stack
-- Executing [s@macro-background-test:3] BackGround("IAX2/carolinanet_iax-7326", "press-2&en/silence/5,,,macro-background-tes") in new stack
-- Playing 'press-2.gsm' (language 'en')
-- Playing 'en/silence/5.gsm' (language 'en')
== Channel 'IAX2/carolinanet_iax-7326' jumping out of macro 'background-test'
[Apr 20 13:42:20] WARNING[11212]: pbx.c:3783 __ast_pbx_run: Channel 'IAX2/carolinanet_iax-7326' sent into invalid extension '2' in context 'macro-background-tes', but no invalid handler
-- Hungup 'IAX2/carolinanet_iax-7326'

This version calls an invalid context, but Asterisk actually tries to look for it.

Any thoughts on what is happening/how to fix it?

Thanks,

Chris


Submitted by eeman on Mon, 04/20/2009 Permalink

you cannot use a macro as an ivr and thus background will not work this way. Since you are using 1.6 you have 2 options..

1) use gosub with arguments instead of macro

2) use the Read command to gather the option and then goto.