Page 1 of 1

Phone alias and Active Agent Server = N

PostPosted: Wed Aug 20, 2014 9:39 am
by okli
Hi, glad to be around again, it's been a while : )

It's a fresh, stock ViciBox 6.0.1 cluster install.
1 Web Server
1 DB Server
2 Telephone servers - 192.168.200.21 (T1) and 192.168.200.22 (T2).
SVN 2163, vicidial.php 2.10-412c 140811-1219, admin.php 2.10-448a 140706-0927.

Crated 2 new SIP phones- 11101 and 21101.
Created a new phone alias, named 102, with a list of phones 11101,21101.

Noone else is loged in.
When for both telephone servers Active Agent Server = Y, and for agent login the alias 102 is used, T2 accepts the call. This seems normal looking at vicidial.php as results from the SQL query are traversed in reverse order.

However, if T2 is set to Active Agent Server = N, while T1 is set to Y, a login error appears, rather failing over to T1.
If T2 is set to Active Agent Server = Y, while T1 is set to N, T2 accepts the call and no error appears.

My idea is to use phone alias, and if anything goes wrong with any of the telephone servers, to set it to Active Agent Server = N and Active Asterisk Server = N and pull it off the cluster while being rebuilt or whatever, at the same time expecting phone alias logins to ignore/skip the removed/disabled server.

My question is is the above described an expected behaviour, or I am missing something.
If it's expected behaviour, what would be the best practise to take temporarily a telephone server off the cluster, without breaking or editing phone alias logins?
Or maybe it's a candidate for a future request?

Re: Phone alias and Active Agent Server = N

PostPosted: Thu Aug 21, 2014 5:19 am
by mflorell
I can't duplicate this problem on our test cluster as you have defined. With the $mel=2 SQL statement logging enabled, the statement appears to be constructed as it should be and it finds the one server active, no matter which one is active if only one of the two is active.

Re: Phone alias and Active Agent Server = N

PostPosted: Thu Aug 21, 2014 5:29 am
by okli
Hi Matt,

The issue as far as I tracked it is in vicidial.php, line 2160 for the mentioned SVN version:

Code: Select all
$desc = ($phones_auto_ct - $pa); # traverse in reverse order


Changing it to :

Code: Select all
$desc = ($phones_auto_ct - $pa - 1); # traverse in reverse order
seems to do the trick.

In brief,
Code: Select all
$phones_auto = explode(',',$phone_login);
returns 0 based array, whereas
Code: Select all
$phones_auto_ct = count($phones_auto);
returns 2 for the count.

$desc = 2 - 0 = 0 on the first loop, but there is no $phones_auto[2], there is only 0 and 1, thus for the first server in backwards order,first login = '', and if this server happens to be the only active one as in the above scenario, login fails.

Here is the broken query with $DB=1
Code: Select all
SELECT count(*) from phones,servers where ((login='' and pass='XXXXXX') or (login='21101' and pass='XXXXXX')) and phones.active = 'Y' and active_agent_login_server='Y' and phones.server_ip=servers.server_ip;
Please note the first login=''.

Re: Phone alias and Active Agent Server = N

PostPosted: Fri Aug 22, 2014 8:02 am
by mflorell
Thank you very much for the detailed explanation, I have fixed this in svn/trunk.

Re: Phone alias and Active Agent Server = N

PostPosted: Sat Aug 23, 2014 9:18 am
by okli
Thanks Matt.

Appologies for the lengthy answer, you'd be the last person who'd need all the details, just didn't have the time to shorten it to a reasonable length.