beonice
2005-Feb-17 06:39 UTC
[Asterisk-Users] Having trouble with extensions in an include file and retrieve_extensions_from_mysql.pl
Folks, I've been running asterisk successfully using the extensions.conf and voicemail.conf. Now that I've got asterisk happily looking up MySQL tables for the VM configuration, I decided to try out the contributed script /usr/src/asterisk/contrib/scripts/retrieve_extensions_from_mysql.pl I edited the script so that its output goes to a separate extensions_from_mysql.conf file. The resulting extensions_from_mysql.conf file looks something like this: [vp_context] exten => 1000,1,Record(/tmp/rec:gsm) ; exten => 1000,2,Playback(/tmp/rec) ; exten => 1000,3,Background(goodbye) ; exten => 1000,4,Hangup() ; I decided to #include this in my main extensions.conf, like so: [main_vp_context] exten => s,1,Answer #include <extensions_from_mysql.conf> exten => #,1,Background(goodbye) ; Notify caller exten => #,2,Hangup() ; Hang up exten => t,1,Hangup() ; Hang up if timeout exten => i,1,Playback(invalid) ; Play "invalid ; extension" if caller ; misdials an extension Basically, I expect asterisk to load the two as separate contexts, and I could swear that it used to. In fact, when I set the verbosity higher, asterisk is definitely still loading them as separate contexts. As of yesterday, though, when I have this format, asterisk won't accept incoming calls. It barfs with the message: Feb 16 21:53:14 NOTICE[4330]: chan_iax2.c:5757 socket_read: Rejected connect attempt from 66.234.228.170, request '##########@voicepulse_connect_context' does not exist The only way to get asterisk to receive calls again is to edit the included file to ensure it does not have a context line in it. So I commented out the line where the retrieve_extensions_from_mysql.pl sticks the context information into the created file. Now, it all works fine. But it's no good. What about when I want to have a sip.conf and have a list of extensions that do different things in the sip context? I really like the contributed script for its ability to add multiple context sections. Anyone see a possible reason for the problem? Do you have any ideas how to use an include file which contains multiple contexts? Or will I have to generate multiple include files, one per included context, without the context lines in these files? Thanks for any help! Cheers, Maya __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail
Andrew Thompson
2005-Feb-17 07:30 UTC
[Asterisk-Users] Having trouble with extensions in an include file and retrieve_extensions_from_mysql.pl
beonice wrote:> The resulting extensions_from_mysql.conf file looks > something like this: > [vp_context] > exten => 1000,1,Record(/tmp/rec:gsm) ; > exten => 1000,2,Playback(/tmp/rec) ; > exten => 1000,3,Background(goodbye) ; > exten => 1000,4,Hangup() ; > > I decided to #include this in my main extensions.conf, > like so: > > [main_vp_context] > exten => s,1,Answer > #include <extensions_from_mysql.conf> > exten => #,1,Background(goodbye) ; Notify caller > exten => #,2,Hangup() ; Hang up > exten => t,1,Hangup() ; Hang up if timeout > exten => i,1,Playback(invalid) ; Play "invalid > ; extension" if caller > ; misdials an extension ><snip>> Anyone see a possible reason for the problem? Do you > have any ideas how to use an include file which > contains multiple contexts? Or will I have to generate > multiple include files, one per included context, > without the context lines in these files?The only thing that seems out of place to me is your #include in [main_vp_context]. It looks to me like you intend for the s, #, t, and i extensions to be in [main_vp_context]. The way you layed out this example, that's not what is happenning. I think you wanted this: Your extensions_from_mysql.conf should still look like: [vp_context] exten => 1000,1,Record(/tmp/rec:gsm) ; exten => 1000,2,Playback(/tmp/rec) ; exten => 1000,3,Background(goodbye) ; exten => 1000,4,Hangup() ; Then, in extensions.conf: #include <extensions_from_mysql.conf> [main_vp_context] exten => s,1,Answer exten => #,1,Background(goodbye) ; Notify caller exten => #,2,Hangup() ; Hang up exten => t,1,Hangup() ; Hang up if timeout exten => i,1,Playback(invalid) ; Play "invalid ; extension" if caller ; misdials an extension include => vp_context This way, you define both contexts, and include the extensions that were defined in [vp_context] into [main_vp_context]. I don't know if this will resolve your other problem, but I believe this is the dialplan you were trying to build. -- Andrew Thompson http://aktzero.com/ http://dev.asteriskdocs.org/