kirm / sip.js

Session Initiation Protocol for node.js
MIT License
427 stars 171 forks source link

UDP Transport rules specify use of `received` header parameter. #134

Open jeremy-j-ackso opened 5 years ago

jeremy-j-ackso commented 5 years ago

UDP Transport rules in RFC 3261 specify the following:

Otherwise (for unreliable unicast transports), if the top Via has a "received" parameter, the response MUST be sent to the address in the "received" parameter, using the port indicated in the "sent-by" value, or using port 5060 if none is specified explicitly.

However, in practice it appears that this library is attempting to use the rules for TCP for UDP as well, which allow re-using the connection, and therefore sending the response back to the sending address:port if it's still open rather than using the received parameter in the header.

It should be sending the UDP response using this address: request.headers.via[0].params.received and a port of request.headers.via[0].params['sent-by'] if present, or 5060 if not present.

jeremy-j-ackso commented 5 years ago

And it looks like the exception to this is when rport=XXXX is present per RFC 3581.