Summary: | ASTERISK-30042: res_pjsip_transport_websocket: Registration over websocket returns a rewritten contact | ||
Reporter: | Thomas Guebels (tguescaux) | Labels: | |
Date Opened: | 2022-05-03 04:09:42 | Date Closed: | 2022-05-13 08:58:17 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | Resources/res_pjsip_registrar Resources/res_pjsip_transport_websocket |
Versions: | 18.7.1 | Frequency of Occurrence | Constant |
Related Issues: | |||
Environment: | Attachments: | ||
Description: | When registering over WebSocket using SIP.js, res_pjsip_transport_websocket rewrites the {{k2km30gagse1.invalid}} host in the contact that is sent in the REGISTER request. The original host is replaced by the apparent ip:port from where the request came from. This is then stored as the contact uri in res_pjsip.
{code} REGISTER sip:dev.elan.escaux.com SIP/2.0 Via: SIP/2.0/WSS k2km30gagse1.invalid;branch=z9hG4bK6030502 To: <sip:identity@localhost> From: <sip:identity@localhost>;tag=31mhoq79ir CSeq: 3 REGISTER Call-ID: o5n3ln3aog19bdpt5bv6 Contact: <sip:bhe74v8j@k2km30gagse1.invalid;transport=ws>;expires=600 User-Agent: SIP.js/0.20.0 {code} In the REGISTER response, this rewritten contact is sent back to SIP.js, triggering the following error, as SIP.js can't find back the contact it tried to register. {code} SIP/2.0 200 OK Via: SIP/2.0/WSS k2km30gagse1.invalid;rport=42956;received=172.16.123.123;branch=z9hG4bK4399238 To: <sip:identity@localhost>;tag=z9hG4bK4399238 From: <sip:identity@localhost>;tag=31mhoq79ir Call-ID: o5n3ln3aog19bdpt5bv6 CSeq: 3 REGISTER Contact: <sip:bhe74v8j@172.16.123.123:42956;transport=ws>;expires=599 Server: Asterisk PBX 18.7.1 {code} bq. No Contact header pointing to us, dropping response from https://github.com/onsip/SIP.js/blob/master/src/api/registerer.ts#L421 It is worth noting that this doesn't happen with the default SIP.js config in which it is more lenient and only verifies the user part of the contact. However, when you specify a custom contact user in the its configuration, it does the full check user@ip:port as per the RFC. This probably explains why one doesn't encounter that bug right away when trying SIP.js + asterisk. See https://github.com/onsip/SIP.js/blob/master/src/api/registerer.ts#L401 I tested a fix which is to save the original contact host in an x-ast-orig-host contact parameter, pretty much like it is done in res_pjsip_nat. It fixes my problem. If you think it is the right way to solve this I can provide a patch. | ||
Comments: | By: Asterisk Team (asteriskteam) 2022-05-03 04:09:43.939-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. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed. 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]. Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur. Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/]. By: Joshua C. Colp (jcolp) 2022-05-03 04:14:48.117-0500 Yes, using that would be the correct way to fix this. You can attach a patch, or the best way to see it included is to put it up for code review on Gerrit. By: Thomas Guebels (tguescaux) 2022-05-05 08:12:43.155-0500 I put my patch up on Gerrit. While it works, I'm not that satisfied with it: it duplicates some code from res_pjsip_nat and the restoration of the contact host is actually done in res_pjsip_nat since its on_tx_response hook gets executed. I'm looking forward to guidance on how to integrate it better. By: Friendly Automation (friendly-automation) 2022-05-13 08:58:18.931-0500 Change 18513 merged by Friendly Automation: res_pjsip_transport_websocket: save the original contact host [https://gerrit.asterisk.org/c/asterisk/+/18513|https://gerrit.asterisk.org/c/asterisk/+/18513] By: Friendly Automation (friendly-automation) 2022-05-13 09:01:32.489-0500 Change 18512 merged by Friendly Automation: res_pjsip_transport_websocket: save the original contact host [https://gerrit.asterisk.org/c/asterisk/+/18512|https://gerrit.asterisk.org/c/asterisk/+/18512] By: Friendly Automation (friendly-automation) 2022-05-13 09:06:37.637-0500 Change 18531 merged by Friendly Automation: res_pjsip_transport_websocket: save the original contact host [https://gerrit.asterisk.org/c/asterisk/+/18531|https://gerrit.asterisk.org/c/asterisk/+/18531] By: Friendly Automation (friendly-automation) 2022-05-13 09:23:23.891-0500 Change 18511 merged by Joshua Colp: res_pjsip_transport_websocket: save the original contact host [https://gerrit.asterisk.org/c/asterisk/+/18511|https://gerrit.asterisk.org/c/asterisk/+/18511] |