[Home]

Summary:ASTERISK-26728: Unique channel names per server
Reporter:Andreas Krüger (woopstar)Labels:
Date Opened:2017-01-18 08:41:15.000-0600Date Closed:2017-01-18 08:53:07.000-0600
Priority:CriticalRegression?
Status:Closed/CompleteComponents:Channels/chan_pjsip
Versions:13.13.1 14.2.1 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:We ran into a interesting issue today. We have two servers who both share the same mysql database as backend and are working as a gateway between external calls and internal calls. When people ring, a ODBC write event adds the channel to our database so we can see which active channels / calls there is.
Suddenly our data seemed corrupted and the system misbehaved a lot.

Tracking down the issue is that the same SIP trunk is shared on both servers due to the servers sharing the database. As we restarted both servers at the same time, the channel names was made of the sip/endpoint name and a channel counter. But as the have the same name and the counter was reset on the same time (due to restart), both servers actually made the same channel names and not unique names.

Our current fix is currently to modify the chan_pjsip.c file before compile and change the
{code}
// Line 71
static unsigned int chan_idx;
{code}

and set a random start number (seeding the server) etc:

{code}
// Line 71
static unsigned int chan_idx = 0x5000;
{code}

Ideally you would add something server specific (id, uuid) or something to the channel name.

My suggestion would be to alter the chan_pjsip_new function in chan_pjsip.c.

I would suspect the place to alter would be this:

https://github.com/asterisk/asterisk/blob/master/channels/chan_pjsip.c#L456

Reference file is: https://github.com/asterisk/asterisk/blob/master/channels/chan_pjsip.c
Comments:By: Asterisk Team (asteriskteam) 2017-01-18 08:41:16.416-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Joshua C. Colp (jcolp) 2017-01-18 08:53:07.731-0600

This functionality already exists in the form of a channel uniqueid. Its purpose is to be a unique identifier for a channel and when the systemname option is set it is guaranteed to be globally unique across your installations. You can also use the autosystemname option to use the hostname of the system itself automatically.

By: Andreas Krüger (woopstar) 2017-01-19 03:47:49.432-0600

Hi @jcolp (Joshua),

Thanks you for the reply to this. I am not sure I agree with you. Looking into the documentation at https://wiki.asterisk.org/wiki/display/AST/Using+the+CONTEXT,+EXTEN,+PRIORITY,+UNIQUEID,+and+CHANNEL+Variables , it says that:

"The UNIQUEID is in the form of 1267568856.11, where 1267568856 is the Unix epoch, and 11 shows that this is the eleventh call on the Asterisk system since it was last restarted."

I cannot see how settings the systemname would make it globally unique.

Restarting two servers at the same time, would result in the same epoch and channel count?

Further. How do you get / lookup a channel if you only have the uniqueid via AEL/AMI etc.

By: Asterisk Team (asteriskteam) 2017-01-19 03:47:49.866-0600

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Joshua C. Colp (jcolp) 2017-01-19 05:14:14.790-0600

The system name, when set, is placed at the front of the uniqueid to make it unique.

As well anywhere you can use a channel name you should be able to use a uniqueid.