[OpenSIPS-Users] Intercepting a 302 response and dispatching an INVITE to a new destination set

Blagovest Buyukliev blagovest at voipfone.co.uk
Tue Sep 5 09:52:01 EDT 2017


Hello,

We are using OpenSIPS 2.3.1 as a proxy to dispatch requests between an external network (referred to as "EN") and a few different destination sets of local SIP servers (referred to as "LS1", "LS2", "LS3", etc.).

The basic architecture looks like this:

EN <-> OSIPS <-> (LS1, LS2, LS3, ...)

The current setup worked well for us until we implemented a feature in the first set of local servers (LS1) which makes them send a "302 Moved Temporarily" response to certain INVITEs matching a specific criteria. With this feature on, a typical (and unwanted) SIP conversation becomes:

1) EN -> OSIPS: "1 INVITE"
2) OSIPS -> LS1[x]: "1 INVITE" (adds Record-Route and Via headers)
3) LS1[x] -> OSIPS: "100 Trying"
4) LS1[x] -> OSIPS: "302 Moved Temporarily" (request must be handled by a
local server from a different set, say LS3)
5) OSIPS -> EN: "302 Moved Temporarily"
6) EN -> OSIPS: "1 ACK"

The external network simply replies with an ACK to the 302, but doesn't initiate a new INVITE to what's indicated in the Contact header of the 302 response.

To go around this problem, my action plan is to prevent OpenSIPS from passing back the 302 to EN in point 5 and instead dispatch the original INVITE to a random server from LS3, which would result in a conversation similar to this:

1) EN -> OSIPS: "1 INVITE"
2) OSIPS -> LS1[x]: "1 INVITE" (adds Record-Route and Via headers)
3) LS1[x] -> OSIPS: "100 Trying"
4) LS1[x] -> OSIPS: "302 Moved Temporarily"
5) OSIPS -> LS3[y]: "1 INVITE"
6) LS3[y] -> OSIPS: "200 OK"
7) OSIPS -> EN: "200 OK"
8) EN -> OSIPS: "1 ACK"

However, implementing that behaviour turned out to be very hard, considering my limited knowledge of OpenSIPS.

The particular problems that I encountered were:

a) Not being able to drop the 302 from "onreply_route", since the drop() function seems to be able to drop only 1xx provisional responses;
b) Not being able to call any of the dispatcher functions for switching to a new destination in "onreply_route".

Is there a way to let OpenSIPS handle the 302 not as a normal reply but as a failure in "failure_route", where the dispatcher functions can be called?

In general, is the latter conversation flow possible to implement with OpenSIPS, or maybe a better solution exists?

Regards,
Blagovest


More information about the Users mailing list