Page 1 of 1

Loadbalace your phone - your WEBPHONE (Viciphone) SCRIPT

PostPosted: Thu May 24, 2018 2:19 pm
by vkad
Code: Select all
if ($is_webphone == 'Y') {
   $stmt = "SELECT srvs.server_ip, srvs.server_description, count(vla.server_ip) as live_agents_count
         FROM vicidial_live_agents vla RIGHT JOIN servers srvs ON vla.server_ip = srvs.server_ip
         GROUP BY srvs.server_ip
         ORDER BY live_agents_count ASC LIMIT 1";
   $sql = mysql_to_mysqli($stmt, $link);
   $row = mysqli_fetch_row($sql);
   
   echo "<!-- SQL Statement: {$stmt} " . print_r($row, true) . " -->";
   
   
   $new_server_ip = $row[0];
   $domain_name = $row[1];

   $conf_override = "context=default" . PHP_EOL;
   $conf_override .= "transport=ws,wss,udp" . PHP_EOL;
   $conf_override .= "encryption=yes" . PHP_EOL;
   $conf_override .= "icesupport=yes" . PHP_EOL;
   $conf_override .= "avpf=yes" . PHP_EOL;
   $conf_override .= "nat=comedia" . PHP_EOL;
   $conf_override .= "directmedia=no " . PHP_EOL;
   $conf_override .= "dtlsenable=yes" . PHP_EOL;
   $conf_override .= "dtlsverify=no " . PHP_EOL;
   $conf_override .= "dtlscertfile=/etc/certbot/live/$domain_name/cert.pem" . PHP_EOL;
   $conf_override .= "dtlsprivatekey=/etc/certbot/live/$domain_name/privkey.pem" . PHP_EOL;
   $conf_override .= "dtlssetup=actpass" . PHP_EOL;

   $stmt = "UPDATE phones SET active='Y', server_ip='$new_server_ip', conf_override='$conf_override' WHERE
extension='$phone_login' ";
   mysql_to_mysqli($stmt, $link);

   $stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
   mysql_to_mysqli($stmt, $link);

   $stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";

   $sql = mysql_to_mysqli($stmt, $link);
   while ($row = mysqli_fetch_row($sql)) {
      $domain_name = $row[0];
      $url = "https://$domain_name/conf_rebuild_phones.php";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
      curl_setopt($ch, CURLOPT_USERAGENT, 'dialer_agent');
      curl_exec($ch);
      curl_close($ch);
   }
   echo "<!-- >> Phone {$phone_login} moved to server: {$domain_name} with ip: {$new_server_ip} -->";

}


So the above code works, but sometimes agents aren't able to register after logging in and "reg failed" shows on viciphone. Trying to login multiple times sometimes fixes the problem.

Can someone help me fix this.....

Thanks.

Re: Loadbalace your phone - your WEBPHONE (Viciphone) SCRIPT

PostPosted: Thu May 24, 2018 2:41 pm
by williamconley
1) Welcome to the Party! 8-)

2) As you are obviously new here, I have some suggestions to help us all help you:

When you post, please post your entire configuration including (but not limited to) your installation method (7.X.X?) and vicidial version with build (VERSION: 2.X-XXXx ... BUILD: #####-####).

This IS a requirement for posting along with reading the stickies (at the top of each forum) and the manager's manual (available on EFLO.net, both free and paid versions)

You should also post: Asterisk version, telephony hardware (model number is helpful here), cluster information if you have one, and whether any other software is installed in the box. If your installation method is "manual/from scratch" you must post your operating system with version (and the .iso version from which you installed your original operating system) plus a link to the installation instructions you used. If your installation is "Hosted" list the site name of the host.

If this is a "Cloud" or "Virtual" server, please note the technology involved along with the version of that techology (ie: VMware Server Version 2.0.2). If it is not, merely stating the Motherboard model # and CPU would be helpful.

Similar to This:

Vicibox X.X from .iso | Vicidial X.X.X-XXX Build XXXXXX-XXXX | Asterisk X.X.X | Single Server | No Digium/Sangoma Hardware | No Extra Software After Installation | Intel DG35EC | Core2Quad Q6600

3) Post the debug output from the failed registration attempt. Is there asterisk output? Dropped packets? Something is failing before the 'fail' message is sent to the agent screen. That information would likely be Very Helpful. 8-)

Re: Loadbalace your phone - your WEBPHONE (Viciphone) SCRIPT

PostPosted: Fri May 25, 2018 2:04 pm
by vkad
Not realated to a hardware, but addition to the /agc/vicidial.php file on vicibox 8 default svn for allowing loadbalanced webrtc