Page 1 of 1
Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Mon May 14, 2018 9:06 am
by vkad
As per matt:
"Let's say you have 3 servers:
10.0.0.11
10.0.0.12
10.0.0.13
and you have an agent phone you want to phone-load-balance-login across all three servers, you would need to create a phones entry for that phone on each server with a different login:
101a -> 10.0.0.11
101b -> 10.0.0.12
101c -> 10.0.0.13
Then you go into to add a new alias(101x) for this set of phone logins which has this as the extension:
101a,101b,101c
Then the agent logs in with 101x as the phone login and tada, it works!
"
NOW how will this setup work in a situation where Viciphone is being used???
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Mon May 14, 2018 9:57 am
by mflorell
It would work exactly the same way.
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Mon May 14, 2018 4:01 pm
by ngtechnologies
The problem that we had with webphones, well not a problem as much as an inconvenience, was that each dialing server had its own template for the ssl certs. So each phone created needed to have the correct template.
Example:
We create 10 phones across 4 dialing servers, 40 phones total. We needed to adjust each phone and change the template to match the server and phone (40 times).
Would be great if there was a way to set 1 template to work in all phones, and add that to the bulk phone insert utility. Be able to have a bulk phone creation with the appropriate template included.
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Mon May 14, 2018 9:33 pm
by vkad
We use alphanumeric extensions....There is no bulk way to add them.
Is it possible for this load balancing to be automatic? Or maybe have a checkbox on each phone to show which servers it can be load balanced on -> This way you can have pseudo names generated form a single login.
Also will viciphone be automatically load balanced to one of the dialers?
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Tue May 15, 2018 1:02 pm
by Invictus
just write FQDNs to server description field in servers.
then if phone_login is set as webphone
in agc/vicidial.php
- 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 = mysqli_query($stmt, $link);
$row = mysqli_fetch_row($sql);
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "avpf=yes" . 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' ";
mysqli_query($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysqli_query($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysqli_query($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);
}
}
create conf_rebuild_phones.php in every asterisk server in cluster;
- Code: Select all
<?php
if ($_SERVER['HTTP_USER_AGENT'] == 'dialer_agent') {
exec("sudo /usr/share/astguiclient/ADMIN_keepalive_ALL.pl > /dev/null 2>/dev/null &");
}
?>
in sudoers you need to give permission to apache to run keepalive script.
in ssh
- Code: Select all
echo "wwwrun ALL=(ALL:ALL) NOPASSWD: /usr/share/astguiclient/ADMIN_keepalive_ALL.pl" >> /etc/sudoers
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Wed May 16, 2018 12:21 pm
by vkad
Invictus wrote:just write FQDNs to server description field in servers.
then if phone_login is set as webphone
in agc/vicidial.php
- 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 = mysqli_query($stmt, $link);
$row = mysqli_fetch_row($sql);
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "avpf=yes" . 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' ";
mysqli_query($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysqli_query($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysqli_query($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);
}
}
create conf_rebuild_phones.php in every asterisk server in cluster;
- Code: Select all
<?php
if ($_SERVER['HTTP_USER_AGENT'] == 'dialer_agent') {
exec("sudo /usr/share/astguiclient/ADMIN_keepalive_ALL.pl > /dev/null 2>/dev/null &");
}
?>
in sudoers you need to give permission to apache to run keepalive script.
in ssh
- Code: Select all
echo "wwwrun ALL=(ALL:ALL) NOPASSWD: /usr/share/astguiclient/ADMIN_keepalive_ALL.pl" >> /etc/sudoers
Just love the amazing help from some of you guys....
Thank you so much for this.
Just, so that I am not confused. This script will register the webphone to a server with the lowest live agents....then it will reload that phone on the server....
Also, this will happen everytime an agent tries to login.
No more need to create multiple phone aliases as this script does that for you. right??
Thanks
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Wed May 16, 2018 4:26 pm
by mflorell
Very ingenious solution to the multi-entry phone alias requirement there
Although the additional load from forcing a reloading of the conf files every time an agent logs in might in itself cause some issues on high-volume systems.
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Thu May 17, 2018 5:50 am
by Invictus
mflorell wrote:Very ingenious solution to the multi-entry phone alias requirement there
Although the additional load from forcing a reloading of the conf files every time an agent logs in might in itself cause some issues on high-volume systems.
it doesn't cause any issues so far
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Thu May 17, 2018 6:13 am
by mflorell
The only reason I mention it is that I have seen forced conf file reloading causing problems on a high-volume system. Not specifically your solution, but a client's custom code which forced reloads based upon custom IVR entries. The rapid forced reloads caused Asterisk to freeze sometimes when Asterisk was under high load.
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Thu May 17, 2018 6:27 am
by Invictus
mflorell wrote:The only reason I mention it is that I have seen forced conf file reloading causing problems on a high-volume system. Not specifically your solution, but a client's custom code which forced reloads based upon custom IVR entries. The rapid forced reloads caused Asterisk to freeze sometimes when Asterisk was under high load.
you are right of course, at first I thought I'd have a problem like you mentioned.
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Thu May 17, 2018 10:22 am
by vkad
Invictus wrote:just write FQDNs to server description field in servers.
then if phone_login is set as webphone
in agc/vicidial.php
- 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 = mysqli_query($stmt, $link);
$row = mysqli_fetch_row($sql);
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "avpf=yes" . 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' ";
mysqli_query($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysqli_query($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysqli_query($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);
}
}
create conf_rebuild_phones.php in every asterisk server in cluster;
- Code: Select all
<?php
if ($_SERVER['HTTP_USER_AGENT'] == 'dialer_agent') {
exec("sudo /usr/share/astguiclient/ADMIN_keepalive_ALL.pl > /dev/null 2>/dev/null &");
}
?>
in sudoers you need to give permission to apache to run keepalive script.
in ssh
- Code: Select all
echo "wwwrun ALL=(ALL:ALL) NOPASSWD: /usr/share/astguiclient/ADMIN_keepalive_ALL.pl" >> /etc/sudoers
WHERE in vicidal.php should i place the script above?
Also, if ($is_webphone = 'Y') {
should be if ($is_webphone == 'Y') {
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Thu May 17, 2018 10:24 am
by vkad
mflorell wrote:Very ingenious solution to the multi-entry phone alias requirement there
Although the additional load from forcing a reloading of the conf files every time an agent logs in might in itself cause some issues on high-volume systems.
Hi,
Can this be added with a checkbox in the phone to allow load balancing like this....
This would really help a lot of people using viciphone with multiple dialers.
Thanks
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Thu May 17, 2018 11:26 am
by vkad
I have updated your script a little and it should be added after the user has logged in
- 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} -->";
}
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Fri May 25, 2018 2:10 pm
by vkad
Having issues with the script guys "reg failed" showing on these servers on webrtc after login.
Thanks
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Sat May 26, 2018 5:49 am
by Invictus
vkad wrote:Having issues with the script guys "reg failed" showing on these servers on webrtc after login.
Thanks
did you create conf_rebuild_phones.php file on each server? did you give sudo permissions to apache2?
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Sun May 27, 2018 3:03 pm
by vkad
Invictus wrote:vkad wrote:Having issues with the script guys "reg failed" showing on these servers on webrtc after login.
Thanks
did you create conf_rebuild_phones.php file on each server? did you give sudo permissions to apache2?
yes, I have to log out and then login again sometimes for it to show registered. Any ideas?
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Mon May 28, 2018 2:16 am
by vkad
The issue was that the server ip was not being updated to the $new_server_ip
so in the file $server_ip = $new_server_ip should be present.
I am shocked that this is working for you....
The only way it would work is if the placement is before the query and the $is_webphone = YES (so you are assigning is webphone in the if condition)
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Tue May 29, 2018 4:03 pm
by vkad
mflorell wrote:The only reason I mention it is that I have seen forced conf file reloading causing problems on a high-volume system. Not specifically your solution, but a client's custom code which forced reloads based upon custom IVR entries. The rapid forced reloads caused Asterisk to freeze sometimes when Asterisk was under high load.
Even though our server isn't under high load, we started to experience errors where the agent wouldn't register.
Re: Loadbalace your phone - your WEBPHONE (Viciphone)!
Posted:
Sun Oct 31, 2021 1:45 pm
by GenXOutsourcing
I know this is an old topic to revive, but I have been looking for a solution also.
While setting up an FTP server, i realized that $USER is a variable set for the correct folder on login. So since my servers have the hostname set, I tried to use $HOSTNAME as the variable in the webphone template, and of course it didnt work....... couldnt be that easy.
[Oct 31 14:22:03] ERROR[2824]: rtp_engine.c:3044 ast_rtp_dtls_cfg_parse: dtlscertfile file /etc/letsencrypt/live/$HOSTNAME/cert.pem does not exist or is not readable
[Oct 31 14:22:03] ERROR[2824]: rtp_engine.c:3051 ast_rtp_dtls_cfg_parse: dtlsprivatekey file /etc/letsencrypt/live/$HOSTNAME/privkey.pem does not exist or is not readable
Anyone have an idea or thought how to use the hostname as a variable for the certs folder?