drachtio / drachtio-server

A SIP call processing server that can be controlled via nodejs applications
https://drachtio.org
MIT License
247 stars 93 forks source link

Route header cannot be added to outbound INVITE #97

Open CelsoGalo opened 5 years ago

CelsoGalo commented 5 years ago

Hello Dave! Hope you doing well today.

I need to set Route headers on outbound requests created by my UAC:

srf.createUAC(rURI, {
   headers: {
      Route: 'sip:proxy1;lr''
   }
});

I found out that this is not possible, as I get this on Drachtio logs: 2019-09-12 11:45:49.313619 makeTags - discarding header because client is not allowed to set dialog-level headers: 'Route

On my case it is important the ability to add Route header, actually more than 1. This is common for guiding emergency calls routing on Next Generation 911 services.

Do you think we can allow this?

I know that common procedures for routing through proxy would imply on some server(s) adding Record-Route during the initial INVITE, having back in the response chain the whole list of Record-Routes, then future requests will provide automatically Route headers based on that. Probably the Drachtio UAC takes care of that ;-), I mean, it stores the whole list (from Record-Route) received in the INVITE response, then use it in the future requests by adding the same Route headers list. I understand that you wouldn't want anyone messing on that.

In the other side, by looking to RFC3261 in the topic 12.1.1 (Dialogs / Creation of a Dialog / UAC behavior), we see this:

The route set MUST be set to the list of URIs in the Record-Route header field from the response, taken in reverse order and preserving all URI parameters. If no Record-Route header field is present in the response, the route set MUST be set to the empty set. This route set, even if empty, overrides any pre-existing route set for future requests in this dialog. The remote target MUST be set to the URI from the Contact header field of the response.

The statement This route set, even if empty, overrides any pre-existing route set for future requests in this dialog means to me that it is indeed possible to have a pre-existing Route header supplied for the initial INVITE, but of course it will be completely overridden by the Record-Route list in the response, even if empty.

By the way, a list of Route headers could be allowed, not just one. You find here the Drachtio logs + a network trace: missing-route-header.zip

What do you think, could we have that changed? Thanks a lot!

davehorton commented 5 years ago

I've never understood the need to use Route headers on an initial INVITE, though I have seen it frmo time to time. Does this appear in an IETF spec anywhere?

Anyways, I will have a quick look at the code to see what would be involved in doing this

CelsoGalo commented 5 years ago

That is the case for static routing, meaning the cases where a centralized proxy/gateway has the routes already determined in advance. This is the case for NENA (NG911) solutions, where the routing is determined by the ESRP server. Thanks a lot!