[Home]

Summary:ASTERISK-27131: PJSIP: Registration problems with Polycom phones behind NAT
Reporter:Sergej Kasumovic (sergej)Labels:patch pjsip
Date Opened:2017-07-14 03:11:17Date Closed:
Priority:MajorRegression?
Status:Waiting for Feedback/In ProgressComponents:
Versions:13.17.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) pjsip_register_one_contact.diff
Description:This is not strictly a bug, but what end user will see manifests itself as bug.
The issue affects Polycom phones and only if they are behind NAT and Asterisk server is somewhere else.

Consider the following scenario:
* Asterisk is publicly available and it is irrelevant if it is behind NAT or not
* Polycom phone is behind NAT. This is important step.
* PJSIP is used
* Endpoint is defined with max_contacts > 1 in aor section
* We define all options necessary to combat NAT (such as rewrite_contact=yes, force_rport, rtp_symmetric etc)
* We register couple of different devices (softphones) with different registration expiry times on the same endpoint

Now here is the problem with Polycom.

Polycom will try to register and Asterisk will reply with 200 OK with all contacts currently registered to server. Since Polycom is behind NAT and we use rewrite_contact option, Polycom phone will not be able to find its Contact in response and will use the first one from the list.

If the first one from the list, does not match its ;expires=T time, Polycom's registration timer will simply not work. What happens is that the phone won't re-register on time, will start losing registration as well as displaying messages about 'registration failure' on display and so on.

One can easily replicate this with all Polycom models (VVX, Soundpoints etc).

This used to work perfectly in chan_sip and of course it will work perfectly in PJSIP if max_contacts=1 and remove_existing=yes are set. The reason for it is that the only one Contact will be returned and this one will have correct ;expires parameter.

It will also work if Asterisk and Polycom are in same network, as the phone will find the relevant Contact in the list.  

So I am attaching a patch.
It is not perfect and you probably won't accept the way it is as it is not what the RFC says (return all bindings).
What it does is that it will simply return the one and only Contact header that we got on register.
Possibly this should be rewritten to have config option or something.
Comments:By: Asterisk Team (asteriskteam) 2017-07-14 03:11:18.971-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: Rusty Newton (rnewton) 2017-07-19 13:32:28.759-0500

[~sergej] , I spoke with the core Asterisk dev team and it seems like this would be accepted as a config option. Can you rework it towards that and push it into Gerrit?



By: Sergej Kasumovic (sergej) 2017-07-25 02:30:53.237-0500

Ok, will re-work the patch with additional config option.

By: Rusty Newton (rnewton) 2017-07-25 13:47:50.334-0500

Very cool. Thanks Sergej!

By: Joshua C. Colp (jcolp) 2017-12-20 06:19:50.312-0600

Did you rework this based on the feedback?

By: Kevin Harwell (kharwell) 2018-07-11 14:41:26.744-0500

Yes this functionality should be wrapped in a config option.

[~sergej] have you been able to update the patch?

Also once done if you'd like your contribution to be included faster, you should submit your patch for code review by the Asterisk Developer Community. To do so, please follow the Code Review [1] instructions on the wiki. Be sure to:
* Verify that your patch conforms to the Coding Guidelines [2]
* Review the Code Review Checklist [3] for common items reviewers will look for
* If necessary, provide tests for the Asterisk Test Suite that verify the correctness of your patch [4]

When ready, submit your patch and any tests to Gerrit [5] for code review.

Thanks!

[1] https://wiki.asterisk.org/wiki/display/AST/Code+Review
[2] https://wiki.asterisk.org/wiki/display/AST/Coding+Guidelines
[3] https://wiki.asterisk.org/wiki/display/AST/Code+Review+Checklist
[4] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Test+Suite+Documentation
[5] https://wiki.asterisk.org/wiki/display/AST/Gerrit+Usage