Dynamic queue members marked invalid after restart

I am using dynamic queue members managed like the example in queues-with-callback-members.txt. Whenever asterisk is restarted the queue members are still there when I do a ‘queue show’ in the CLI, but they are marked as Invalid and no calls will go to them from the queue (normally dialed calls work fine).

This happens with either a restart gracefully or restart now, and after going back into the CLI if I do a ‘reload’ the member is marked as not in use and is rung normally.

I have persistentqueuemembers = yes . The rest of the queue.conf:

[general]
persistentmembers = yes
autofill = yes

[supportq]
strategy = roundrobin
context = supportqout
timeout = 20
retry = 3
maxlen = 0
announce-frequency = 90
announce-holdtime = no
joinempty = yes

The only thing I have set in agents.conf is persistentmembers = yes. Is this file really needed with dynamic members? It doesn’t look like Add/Re moveQueueMember uses it at all.

The members are added with

and removed similarly.

The staff-queue context members are in:

context staff-queue {

        includes { parkedcalls; }

        _14X => Dial(SIP/${EXTEN},20,t);
        _13X => Dial(SIP/${EXTEN},20,t);
        _102 => Dial(SIP/132,20,t);
        _103 => Dial(SIP/133,20,t);
        _104 => Dial(SIP/134,20,t);
        _105 => Dial(SIP/135,20,t);
        _1XX => Dial(SIP/${EXTEN},20,t);

        i => {
                Playback(NetPBX/invalid-extension);
                Hangup();
        }
};

the reason I’m doing it that way is that the phones are 7960’s and those who are regularly logged into the queue have a line just for that (the 13X extensions). 14X is used for remote soft-phone users, and the 10x’s are the “normal” phone extensions.

Since I haven’t yet found a fix for this I have created a workaround. I made a script to check via the manager API how long since asterisk was last restarted or reloaded, and reload the config if it has been less than 5 minutes since a restart or there is no reload time. I have this running every 5 minutes via cron.

I’m not a programmer and this is by far the most complex php i’ve ever done (and it is really pretty simple), so there might be a better way to do this or do it more efficiently, but it works well enough for me.

[code]#!/usr/bin/php -q

<?php // this script checks how long asterisk has been up. If less // than 5 minutes, it will reload the configuration to work // around the dynamic queue members invalid problem. $manager_ip = "127.0.0.1"; $manager_port = "5038"; $manager_user = "USER"; $manager_pass = "PASS"; $uptime_command = "core show uptime seconds"; $reload_command = "reload"; $timeout = 10; $socket = fsockopen($manager_ip,$manager_port,$errno,$errstr,$timeout); if (!$socket) { echo "$errstr ($errno)\n"; } else { $cmdlist = "Action: Login\r\n"; $cmdlist .= "UserName: $manager_user\r\n"; $cmdlist .= "Secret: $manager_pass\r\n\r\n"; $cmdlist .= "Action: Command\r\n"; $cmdlist .= "Command: $uptime_command\r\n\r\n"; $cmdlist .= "Action: Logoff\r\n"; fwrite($socket, $cmdlist); $output = ''; $output_tmp = ''; $end_pattern = '/^--END/'; while (!feof($socket)) { $output_tmp .= fgets($socket, 128); if(preg_match($end_pattern, $output_tmp)) { $output .= $output_tmp; break 1; } else { $output .= $output_tmp; $output_tmp = ''; } } fclose($socket); } $arr_output = explode("\n", $output); $uptime = 0; $reloadtime = 0; $uptime_pattern = '/\buptime\b/'; $reload_pattern = '/\breload\b/'; $line = ''; while (count($arr_output)) { $line = array_shift($arr_output); if(preg_match($uptime_pattern, $line)) { $uptime = str_replace("System uptime: ", "", $line); } elseif (preg_match($reload_pattern, $line)) { $reloadtime = str_replace("Last reload: ", "", $line); } } if($uptime > 300 && $reloadtime > 0) { // echo "asterisk has been up longer than 5 minutes.\n"; // echo "asterisk has been reloaded since the last restart\n"; } elseif($uptime < 300 || $reloadtime = 0) { echo "asterisk has been restarted in the last 5 minutes "; echo "or it has not been reloaded.\n"; echo "reloading configuration...\n"; $socket = fsockopen($manager_ip,$manager_port,$errno,$errstr,$timeout); if (!$socket) { echo "$errstr ($errno)\n"; } else { $cmdlist = "Action: Login\r\n"; $cmdlist .= "UserName: $manager_user\r\n"; $cmdlist .= "Secret: $manager_pass\r\n\r\n"; $cmdlist .= "Action: Command\r\n"; $cmdlist .= "Command: $reload_command\r\n\r\n"; $cmdlist .= "Action: Logoff\r\n"; fwrite($socket, $cmdlist); fclose($socket); } } ?>[/code]