freeswitch icon indicating copy to clipboard operation
freeswitch copied to clipboard

SIP Via Header on 100 Trying

Open wpichler opened this issue 5 years ago • 14 comments
trafficstars

Hi all,

following behaviour on freeswitch 1.10.1 - when getting an inbound call from a system behind a sip proxy - then the invite does have 2 Via Headers (Top Via Header from Proxy, second Via Header from system behind proxy). Freeswitch does send a 100 Trying - with only the Top Via Header set. This does cause the proxy to not forward the via header - so we get a second invite and so on.

If freeswitch does answer the call - then it will send a 200 Ok with all Via Headers.

Why does it not send the Via headers in 100 Trying ? Is there a config option for it (i did not found one) ?

In the RFC3261 - 8.2.6.2 is the following: "The Via header field values in the response MUST equal the Via header field values in the request and MUST maintain the same ordering."

So i think freeswitch (libsofia) is acting wrong here...

wpichler avatar Feb 10 '20 08:02 wpichler

Please attach a complete sip trace with debug log.

briankwest avatar Feb 10 '20 13:02 briankwest

maybe this is relevant 100 responses are not forwarded by proxies, so only include the topmost Via header from this https://github.com/signalwire/freeswitch/commit/6ed86abf9f6ab1116a39b28c651dec1d4f6cf89f

lazedo avatar Feb 10 '20 13:02 lazedo

@lazedo Yep - this could be the cause for the problem - i will test tomorrow by disabling this part:

if (sip->sip_status && sip->sip_status->st_status == 100)
  sip->sip_via = (sip_via_t *)msg_header_copy_one(home, (msg_header_t const *)irq->irq_via);
else
  sip->sip_via = sip_via_copy(home, irq->irq_via);

only using sip->sip_via = sip_via_copy(home, irq->irq_via);

@armenfirespotter This part is the nta_incoming_reponse_headers function - so this is in a response to a proxy which did already forwarded the Via Headers - or which inserted the via headers. Why should it here be necessary to remove a Via Header ?

wpichler avatar Feb 10 '20 14:02 wpichler

@lazedo @wpichler this was awhile ago, but the point of FS-9300 was to introduce the acknowledge_call app. At the time, IIRC freeswitch/sofia did not follow the RFC spec re the quoted bit above: it only copied one Via header in a 100 Trying, not the whole Via stack as RFC-compliant implementation should. w.r.t this implementation, I wanted to preserve existing on-the-wire behavior of freeswitch/sofia for compatibility with existing (possibly-non-rfc-compliant) implementations. In retrospect, my comment kinda sucks and doesn't tell this story.

FWIW, I have no objection with bringing this implementation in-line with RFC compliance, perhaps by deleting lines 6465 to 6468, inclusive.

armenfirespotter avatar Feb 10 '20 15:02 armenfirespotter

I've disabled this part - but still the problem exists. So there must be an other point where the sip via headers gets set. In this function it does only work on the via header if it is not already set.

In which part of the code does the SIP Via header for a 100 Trying response are getting set ?

wpichler avatar Mar 04 '20 11:03 wpichler

Any progress on this matter? Or perhaps a workaround?

cmcom-gb avatar Jun 29 '20 07:06 cmcom-gb

Is it possible to enable some flag in the profile to keep the 2 headers via in Trying?

eduardofoliveira avatar Jul 16 '21 16:07 eduardofoliveira

Is there any update on this ticket? The stripping of the Via headers impacts the ability to integrate with stateless proxies that rely on the Via headers.

kriegschrei avatar Jan 27 '22 17:01 kriegschrei

is there any update on this at all?

davidwjacob avatar Jan 18 '23 02:01 davidwjacob

We have same issue. Proxy keep sending invite

gregoriusus avatar Sep 21 '23 15:09 gregoriusus

Bumping thread, any update on this? https://github.com/freeswitch/sofia-sip/pull/41 looks good to merge? If not tell me if not and I will try to make a fix.

killdashnine avatar Mar 19 '24 11:03 killdashnine