[Home]

Summary:ASTERISK-26645: res_pjsip_endpoint_identifier_ip: Does not check for updates in realtime database
Reporter:Ross Beer (rossbeer)Labels:
Date Opened:2016-12-06 09:01:39.000-0600Date Closed:2016-12-06 09:19:51.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_pjsip_endpoint_identifier_ip
Versions:13.12.2 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Fedora 23Attachments:
Description:When storing endpoint identifier entries in a realtime backend, entries are not checked for updates.

I would have expected the table to either be queried periodically or when a SIP device tries to send messages to Asterisk.

If changes are made to the database, the only way for these to be pulled into the asterisk config is to manually run a show command to load it.

The sorcery config is as follows:

{noformat}
[res_pjsip_endpoint_identifier_ip]
identify=config,pjsip.conf,criteria=type=identify
identify/cache=memory_cache,expire_on_reload=yes,full_backend_cache=yes
identify=realtime,ps_endpoint_id_ips
{noformat}

The command used to fetch the data from the database is:

{noformat}
pjsip show identify <ENDPOINT>
{noformat}

Once the command has been run, devices are successfully authenticated via IP.

As this table could be hammered by attempted hackers, I would suggest a periodic check be put in place or negative caching.
Comments:By: Asterisk Team (asteriskteam) 2016-12-06 09:01:39.843-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) 2016-12-06 09:19:51.778-0600

You've configured the memory cache such that all entries are cached indefinitely unless you explicitly, from CLI or AMI, tell it to update. You can use the object_lifetime_maximum and object_lifetime_stale options[1] for the memory cache to update it periodically automatically[2].

[1] https://wiki.asterisk.org/wiki/display/AST/Sorcery+Caching#SorceryCaching-object_lifetime_maximum
[2] https://wiki.asterisk.org/wiki/display/AST/Sorcery+Caching#SorceryCaching-Pre-cachingallobjects

By: Ross Beer (rossbeer) 2016-12-06 09:34:44.763-0600

Joshua,

For clarification, the full backend cache will retrieve all objects as per the below:

{quote}
Just like with the previous section's configuration, we have configured an object to be retrieved from realtime and cached in memory. Notice, though, that we have added full_backend_cache=yes to the end of the line. This is what causes Asterisk to pre-cache the objects. Normally, PJSIP "identify" objects would be a bad fit for caching since we tend to retrieve them all at once rather than one-at-a-time. By pre-caching all objects though, Asterisk can now retrieve all of them directly from the cache. Also notice that the other caching options are still relevant here. Rather than having the options apply to individual objects, they now apply to all of the retrieved objects. So if Asterisk retrieved 10 identifys during pre-cache, when the stale lifetime rolls around, all 10 will be marked stale and Asterisk will once again retrieve all of the objects from the backend.
{quote}

Does this mean that if there are now 15 objects, will the process retrieve all 15 or only the 10 it already knows? Will there be a full cache each time?

By: Asterisk Team (asteriskteam) 2016-12-06 09:34:45.025-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) 2016-12-06 09:51:55.962-0600

If full backend caching is enabled then it would get ALL objects in the database, not simply those it knew about.

By: Ross Beer (rossbeer) 2016-12-07 04:14:09.153-0600

This doesn't work for me, when attempting to make a call after a restart I have to run the command above (pjsip show identify <ENDPOINT>) before calls are allowed.

There are identify sections in the pjsip.conf, therefore I have included this in the sorcery config as above.

As suggested I changed the config to the following and still this isn't working:

{noformat}
[res_pjsip_endpoint_identifier_ip]
identify=config,pjsip.conf,criteria=type=identify
identify/cache=memory_cache,object_lifetime_stale=600,object_lifetime_maximum=1800,expire_on_reload=yes,full_backend_cache=yes
identify=realtime,ps_endpoint_id_ips
{noformat}

By: Asterisk Team (asteriskteam) 2016-12-07 04:14:09.638-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: Ross Beer (rossbeer) 2016-12-07 04:26:29.297-0600

Ok, so after a bit or re-ordering the following appears to work correctly:

{noformat}
[res_pjsip_endpoint_identifier_ip]
identify/cache=memory_cache,object_lifetime_stale=600,object_lifetime_maximum=1800,expire_on_reload=yes,full_backend_cache=yes
identify=config,pjsip.conf,criteria=type=identify
identify=realtime,ps_endpoint_id_ips
{noformat}