BelledonneCommunications / flexisip

Linphone.org mirror for flexisip (git://git.linphone.org/flexisip.git)
http://flexisip.org
GNU Affero General Public License v3.0
140 stars 68 forks source link

Duplicate contact header #186

Open marks-backspace opened 1 month ago

marks-backspace commented 1 month ago

Hi

I have an issue where flexisip creates a duplicate contact header in the OK message after it receives an OK message from the SIP server. flexisip is configured to as a push notification server authentication is done on an external registrar

marks-backspace commented 1 month ago

SAMPLE TRACE SIP SERVER= 10.10.10.10 FLEXISIP = 10.10.10.55 MOBILE APP = 102.219.163.215

# U 10.10.10.10:5060 -> 10.10.10.55:5060 #490 SIP/2.0 200 OK. Via: SIP/2.0/UDP 10.10.10.55;rport=5060;branch=z9hG4bK.NN8aQr5FrgBt3y3S96aZUF5SUa. Via: SIP/2.0/UDP 102.219.163.215:54911;branch=z9hG4bK.YpGW2D664;rport=54911. Path: <sip:10.10.10.10;lr;ep>. Path: <sip:10.10.10.55:5060;fs-proxy-id=b5057c044ea898e4;lr>. Path: <sip:10.10.10.55:5060;lr;ob>. Contact: sip:210233810_207@10.10.10.55:5060;gr=urn:uuid:b42e3edd-dff2-00dc-b7f2-e6b1b2e8e3d1;expires=2678400. To: sip:210233810_207@voice.sipline.mytelecom.co.za;tag=daf74f22. From: sip:210233810_207@voice.sipline.mytelecom.co.za;tag=EkF-BDLfI. Call-ID: YKT60su1YB. CSeq: 25 REGISTER. Date: Thu, 30 May 2024 11:11:35 GMT. Supported: path. PortaBilling: available-funds:5476.72220 currency:ZAR. Content-Length: 0. .

U 10.10.10.55:5060 -> 102.219.163.215:54911 #491 SIP/2.0 200 OK. Via: SIP/2.0/UDP 102.219.163.215:54911;branch=z9hG4bK.YpGW2D664;rport=54911. Path: <sip:10.10.10.10;lr;ep>. Path: <sip:10.10.10.55:5060;fs-proxy-id=b5057c044ea898e4;lr>. Path: <sip:10.10.10.55:5060;lr;ob>. To: sip:210233810_207@voice.sipline.mytelecom.co.za;tag=daf74f22. From: sip:210233810_207@voice.sipline.mytelecom.co.za;tag=EkF-BDLfI. Call-ID: YKT60su1YB. CSeq: 25 REGISTER. Date: Thu, 30 May 2024 11:11:35 GMT. Supported: path. PortaBilling: available-funds:5476.72220 currency:ZAR. Content-Length: 0. Contact: sip:210233810_207@102.219.163.215:54911;pn-prid=f46ihjEfQ8movcsuvr6o2N:APA91bGGPquw0oMrdGUCR4kNGpuY7ctniE-ktM2p_an8dIbjXeaZayoh0FbJJt1UMqd70ecY1USp_wpWDaKPmwYaG8NoHovdcWBEq1SzxgSTmEkxYgMBYDjcJzuGTcfRSAoeeL-HnTwK;pn-provider=fcm;pn-param=279388202439;pn-silent=1;pn-timeout=0;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-groupchat-str=GC_MSG;pn-call-snd=notes_of_the_optimistic.caf;pn-msg-snd=msg.caf;transport=udp;+sip.instance="";+org.linphone.specs="lime";pub-gruu="sip:210233810_207@voice.sipline.mytelecom.co.za;gr=urn:uuid:75de582b-27bd-0059-9f07-111c9743db67". Contact: <sip:210233810_207@102.182.46.47:46644;pn-prid=d_2_ZFSqRmSsDsmV8wXd4N:APA91bEpW77N1GkfIl6cDTNv3rh8js6bI42hMUK_QpCXhNEv2On6t-yIu-zcekqm8HiCsj3WJjmpeJJS7uT0K99AU_w3bnxU_0ok7e4jZdN9eA5GWmKocWgKjQBGwBVY1CN0dv0kzFWH;pn-provider=fcm;pn-param=279388202439;pn-silent=1;pn-timeout=0;pn-msg-str=IM_MSG;pn-call-s

Failxxx commented 3 weeks ago

Hello @marks-backspace, If I understand correctly, you are trying to register a user on an external SIP server and Flexisip should only act as a proxy and a push-notification server? Am I right? I am trying to describe the call-flow in your particular situation, is this right?

SIP UAC (mobile: 102.219.163.215)    SIP server (Flexisip: 10.10.10.55)    SIP Server (external: 10.10.10.10)
               |                                      |                                     |
               |        REGISTER (YKT60su1YB)         |                                     |
               |  -------------------------------->   |                                     |
               |                                      |         REGISTER (YKT60su1YB)       |
               |                                      |   ------------------------------>   |
               |                                      |         200 Ok (YKT60su1YB)         |
               |                                      |   <------------------------------   |
               |         200 Ok (YKT60su1YB)          |                                     |
               |  <------------------------------     |                                     |
               |                                      |                                     |

So the issue you are facing is that the "200 Ok" response sent to the UAC by Flexisip contains two "Contact:" headers whereas it should have forwarded the "Contact:" header from the original "200 Ok" response. Am I right?

marks-backspace commented 3 weeks ago

Hi

If I understand correctly, you are trying to register a user on an external SIP server and Flexisip should only act as a proxy and a push-notification server? Am I right? YES

I am trying to describe the call-flow in your particular situation, is this right?

YES

So the issue you are facing is that the "200 Ok" response sent to the UAC by Flexisip contains two "Contact:" headers whereas it should have forwarded the "Contact:" header from the original "200 Ok" response. Am I right?

**The OK response must forward the contact to the device that sent the register. REGISTER was sent from 210233810_207@102.219.163.215:54911 . This contact :210233810_207@102.182.46.47:46644 is from an older registration and should not be included in the message

Contact: sip:210233810_207@102.219.163.215:54911;pn-prid=f46ihjEfQ8movcsuvr6o2N:APA91bGGPquw0oMrdGUCR4kNGpuY7ctniE-ktM2p_an8dIbjXeaZayoh0FbJJt1UMqd70ecY1USp_wpWDaKPmwYaG8NoHovdcWBEq1SzxgSTmEkxYgMBYDjcJzuGTcfRSAoeeL-HnTwK;pn-provider=fcm;pn-param=279388202439;pn-silent=1;pn-timeout=0;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-groupchat-str=GC_MSG;pn-call-snd=notes_of_the_optimistic.caf;pn-msg-snd=msg.caf;transport=udp;+sip.instance="urn:uuid:75de582b-27bd-0059-9f07-111c9743db67";+org.linphone.specs="lime";pub-gruu="sip:210233810_207@voice.sipline.mytelecom.co.za;gr=urn:uuid:75de582b-27bd-0059-9f07-111c9743db67".**

Failxxx commented 3 weeks ago

Alright, thank you. Can you share flexisip logs (with loglevel set to debug) so I can investigate what could be wrong here please? I may have ideas about what could cause this issue, however I am lacking information to correctly understand the problem.

marks-backspace commented 3 weeks ago

Hi

Thank you , do you have a direct email address where i can forward the email to or share a google drive link?

Failxxx commented 3 weeks ago

Yes, please find the address on my GitHub profile: https://github.com/Failxxx

Failxxx commented 3 weeks ago

Here is what I understand from the logs you sent me: The two "Contact:" headers are expected since I can see REGISTER requests for all of them (call-id: 0hXrKHafba and call-id: eRL4ZSmQP6). Maybe you forgot to turn off a device which is still sending REGISTER requests for this specific account?

Remark: The expiration set in the REGISTER requests is 2678400 (about 1month). However, you probably did not override Flexisip parameter module::Registrar/max-expires which is set to 86400 (1day) by default. This explains why contacts do not stay registered longer than 1 day.

marks-backspace commented 2 weeks ago

Hi

The app is having issues REGISTERING because it when it receive that OK with 2 contact headers it does not recognize the contact and keeps trying to re-register.

I maintain flexisip should send only one contact which is the contact that was originally presended on the register. If there are 2 devices registers it should generate 2 different OK messages each with the appropriate contact information based on tracking the callid

[cid:backspace_03c63df8-50f9-45ae-b134-95f7c9c895fc.png]

Marks Khumalo | VoIP Support and Implementation Specialist | Technical (Support) | www.backspace.co.za | 010 023 0320 |

17 New Church Street, City Bowl, Cape Town, Western Cape, 8000


From: Félix @.> Sent: Friday, June 14, 2024 6:10 PM To: BelledonneCommunications/flexisip @.> Cc: Marks Khumalo @.>; Mention @.> Subject: Re: [BelledonneCommunications/flexisip] Duplicate contact header (Issue #186)

Here is what I understand from the logs you sent me: The two "Contact:" headers are expected since I can see REGISTER requests for all of them (call-id: 0hXrKHafba and call-id: eRL4ZSmQP6). Maybe you forgot to turn off a device which is still sending REGISTER requests for this specific account?

Remark: The expiration set in the REGISTER requests is 2678400 (about 1month). However, you probably did not override Flexisip parameter module::Registrar/max-expires which is set to 86400 (1day) by default. This explains why contacts do not stay registered longer than 1 day.

— Reply to this email directly, view it on GitHubhttps://github.com/BelledonneCommunications/flexisip/issues/186#issuecomment-2168339738, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BJAKTLRITNHB433I7MQGHUDZHMIWBAVCNFSM6AAAAABI6A2C6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRYGMZTSNZTHA. You are receiving this because you were mentioned.Message ID: @.***>

Failxxx commented 2 weeks ago

Hi, As stated in RFC3261, section 10.3, step 8:

The registrar returns a 200 (OK) response. The response MUST contain Contact header field values enumerating all current bindings. [...]

This paragraph means Flexisip MUST return all contact addresses registered in the registrar for the given user. So I believe Flexisip is doing right in this case. However, I admit the problem may be elsewhere in Flexisip. This is also explained in section 10.2.4 (Refreshing Bindings):

[...] The 200 (OK) response from the registrar contains a list of Contact fields enumerating all current bindings. The UA compares each contact address to see if it created the contact address [...]

The problem may also be on client side. Can you share the logs so we can investigate why it does not recognize the contact?