Summary:ASTERISK-28056: res_pjsip: Incorrect endpoint status after endpoint synchronization for a specific AOR
Reporter:Jason Hord (jhord)Labels:patch pjsip
Date Opened:2018-09-14 16:44:04Date Closed:2020-04-06 09:07:17
Versions:13.22.0 15.6.0 16.0.0 Frequency of
is duplicated byASTERISK-28189 configured pjsip endpoints go offline when a new endpoint registers
is duplicated byASTERISK-28388 Endpoint sync causes device unreach when a new contact is added
Environment:Attachments:( 0) 555-aor.txt
( 1) 555-endpoint.txt
( 2) 999-aor.txt
( 3) 999-endpoint.txt
( 4) asterisk_log_13.30.0.txt
( 5) full
( 6) pjsip_options-aor.diff
Description:I have two devices configured but am unable to get them to both consistently qualify after starting Asterisk.  I see the endpoint and AOR for the first device become reachable as expected, but as the second device is being qualified, the endpoint for the first device is marked as 'Unavailable'.  The contact and AOR for both devices are reachable, however.

Based on my digging through the source code and logs, I believe this happens when sip_options_synchronize_endpoint() (res/res_pjsip/pjsip_options.c) is called for a specific AOR.  When called, it appears as though non-matching AORs are checked to see if they have an endpoint state compositor and will be set to an 'Unavailable' status if one is not present.  My thought is that this is what is setting the first endpoint to unavailable although I'm not sure why this would be the case.

I have included a small patch that resolves the issue for me, but I don't know if it is the correct solution.  Any guidance would be appreciated.

Comments:By: Asterisk Team (asteriskteam) 2018-09-14 16:44:05.276-0500

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: Richard Mudgett (rmudgett) 2018-09-14 17:12:44.124-0500

Please provide the configuration for the endpoints and the aors involved.

Also you have not marked the attached patch as a contribution.

By: Jason Hord (jhord) 2018-09-17 11:13:01.168-0500

AOR/Endpoint configuration according to 'pjsip show aor'/'pjsip show endpoint'.

By: Jason Hord (jhord) 2018-09-17 11:15:27.126-0500

I have attached the AOR/Endpoint config for the two extensions.  I didn't mark the attachment as a contribution because my license agreement hasn't been approved yet.

By: Joshua C. Colp (jcolp) 2018-09-18 05:16:35.812-0500

All code changes need to be marked as a code contribution to be properly licensed, please upload a new one once your license agreement has been accepted.

By: Joshua C. Colp (jcolp) 2018-09-18 05:18:41.835-0500

Assigning back to you to re-upload your proposed fix.

By: Jason Hord (jhord) 2018-09-18 07:59:20.925-0500

Re-uploaded patch.

By: Joshua C. Colp (jcolp) 2018-09-24 05:46:24.749-0500

Can you please also include the console log with full debug enabled at level 4? Looking at the code and your change I don't believe it is the correct fix. I think what should happen is that if an AOR is specified and an endpoint state compositor does NOT exist then it should be set to offline. If one does exist then it is managing the state of the endpoint and is providing the updates.

By: Jason Hord (jhord) 2018-09-24 15:28:22.385-0500

Here is the log with verbose/debug set to '4'.  During this run, here is what I saw:

Endpoint 555-Nihil came online and showed available on the contact and endpoint as well as showing the correct device status in a queue.

Endpoint 999-Nihil remained unavailable until the device re-registered.  At that point the endpoint and contact were both marked as available, but after some time the endpoint went unavailable.  The contact was still available but the device status in the queue was incorrect.

I keep seeing log messages like the following:

Endpoint 'XXX' has no AORs feeding it, setting it to offline state as default

I'm not sure why this is the case since all of the AORs and Endpoints should be configured in our realtime database.  It seems there is something amiss with the matching and I can't tell if it's a bug or config issue.  This is a working configuration for 15.2.2, however.

By: Jesse Ross (jmross) 2020-02-13 10:13:33.113-0600

Hi, I believe I am running into this error as well on Asterisk 13.30.0. On 13.20.0, it is working fine. It looks like the commit "pjsip: Rewrite OPTIONS support with new eyes." that is related to this was added around 13.22.0.

I'm using a realtime database for all endpoints, auths, aors, contacts. When I add a new endpoint, then register to it, other registered endpoints become unreachable.

I have a log with debug set to 10 with a few endpoints on a test server that I can upload if you want.

I see the same message:
{{Endpoint 'XXX' has no AORs feeding it, setting it to offline state as default}}

And reloading res_pjsip.so or restarting all clients fixes it.

By: Jesse Ross (jmross) 2020-02-13 10:24:25.333-0600

I just uploaded that log: asterisk_log_13.30.0.txt

There are two endpoints initially: 00 and 01.

I create the endpoint 02 in the database, then register to it, then 00 and 01 become unreachable.

I then run {{module reload res_pjsip.so}} and 00 and 01 become reachable again.

By: Joshua C. Colp (jcolp) 2020-02-13 10:29:23.161-0600

I don't believe any additional information is required here. This issue is already open and known but has not been taken to completion by anyone.

By: Friendly Automation (friendly-automation) 2020-04-06 09:07:20.172-0500

Change 14058 merged by Friendly Automation:
res_pjsip: Don't set endpoint to unavailable in all cases.


By: Friendly Automation (friendly-automation) 2020-04-06 09:16:59.584-0500

Change 14057 merged by George Joseph:
res_pjsip: Don't set endpoint to unavailable in all cases.


By: Friendly Automation (friendly-automation) 2020-04-06 09:17:17.177-0500

Change 14034 merged by George Joseph:
res_pjsip: Don't set endpoint to unavailable in all cases.


By: Friendly Automation (friendly-automation) 2020-04-06 09:17:30.964-0500

Change 14056 merged by George Joseph:
res_pjsip: Don't set endpoint to unavailable in all cases.