Interesting. We did not require any such special handling for it to work on our 
side. We no longer run with shared IPs, though, so maybe something has changed. 
Sorry I couldn't be more help.

Ben Newlin 

On 5/19/20, 10:25 AM, "John Quick" <[email protected]> wrote:

    Hi Ben,

    Thanks for answering this one. I agree totally with your analysis, but I 
can also assure you that the "different" port number is present in the R-URI of 
the ACK.
    This is what OpenSIPS receives, over TLS, from the remote UAC:
    ACK sip:[email protected]:5050;transport=tcp SIP/2.0

    I'm using port 5050 (tcp) on FreeSwitch and ports 5060 (tcp and udp) and 
5061 (tls) on OpenSIPS.

    I'm having to use a work-around at the moment that looks like this 
(slightly edited):
        if (has_totag() && 
is_method("INVITE|ACK|PRACK|BYE|UPDATE|REFER|NOTIFY")) {
            $var(orig_ruri) = $ru;
            $var(orig_rp) = $rp;
            if ( loose_route() ) {
                # Loose-routed request - attempt to match with an existing 
dialog
                match_dialog();

                if ($var(orig_rp) == "5050" && $ru =~ "r2=on") {
                    # Work-around fiddle for sending to an endpoint on the same 
IP as myself
                    $ru = $var(orig_ruri);
                    $du = "sip:" + $rd + ":5050";
                    force_send_socket(tcp:195.XX.YY.ZZ:5060);
                    xlog("L_WARN", "      LR(fixed) $rm  RuProto=$rP   
R-URI=$ru  Dest=$du  Call-ID=$ci\n");
                } else
                    xlog("L_WARN", "      LR $rm   RuProto=$rP  R-URI=$ru  
Call-ID=$ci\n");


    John Quick
    Smartvox Limited


    -----Original Message-----
    From: Ben Newlin <[email protected]> 
    Sent: 19 May 2020 14:37
    To: [email protected]; OpenSIPS users mailling list 
<[email protected]>; 'James Hogbin' <[email protected]>
    Subject: Re: [OpenSIPS-Users] Running OpenSIPS on same box as 
Asterisk/FreeSwitch

    John,

    This is occurring because the local OpenSIPS is seeing its own local URI in 
the R-URI and is (correctly) assuming the message is meant for it. At that 
point there is some ambiguity in the situation as even though the Route headers 
indicate loose routing, OpenSIPS cannot leave the R-URI as is, because it will 
just loop back to itself. So it is instead assuming that strict-routing is 
being used and following that model.

    We also run with different servers sharing IPs and we ran into this too. 
You say the two servers are using different ports, but I am guessing that the 
R-URI doesn't actually contain the port. That is why there is confusion. The 
only fix I know is to ensure that every server sharing an IP always includes 
its local port in the Contact header. This will cause all sequential requests 
to also contain the port in their R-URI. This differentiates the R-URI so that 
OpenSIPS will no longer believe the message is directed to it and will follow 
normal loose routing procedures.

    I'm not really sure whether there could be any improvement in OpenSIPS that 
could handle this, since the situation is inherently ambiguous.

    Ben Newlin 

    On 5/19/20, 3:56 AM, "Users on behalf of John Quick" 
<[email protected] on behalf of [email protected]> wrote:

        Hi James and others,

        James, I have provided some explanation and guidance specific to you at 
the end of this post. First, I need to retract some of the explanation I gave 
in my original post because it was wrong. The basic problem is as described - 
handling of loose routed sequential requests goes wrong when OpenSIPS is 
running on the same host server as Asterisk or FreeSwitch, using the same IP 
but different ports.

        I think the correct explanation for what is happening is this: 
        Where the address in the R-URI is the same as its local address, 
OpenSIPS copies the URI (and parameters) from a Route header to the R-URI 
which, in this use-case, causes the request to loop back to itself. It should 
instead delete the two Route headers and leave the original R-URI value 
unchanged.

        James, what you describe is not identical to my issue, although you may 
have my issue plus another.
        It should be fairly easy for you to fix the problem of private LAN 
addresses being used where you want external IP's to be used.
        OpenSIPS handles this issue through the "advertised address". This 
allows it to listen on one interface, but to populate SIP headers such as Via 
and Record-Route with another.
        Various mechanisms are available to add to your script including the 
following:
        1) Define it for each interface in the listen statement: e.g.  listen = 
tls:10.x.x.x:5091 as <External IP>:5091
        2) Global settings at the top of your script:  advertised_address and 
advertised_port
        3) Within the main body of your script, e.g. just before the call to 
record_route(), insert a line like: set_advertised_address(<External IP>);
        4) Instead of calling record_route(), call 
record_route_preset(<address1:port>,<address2:port>); 
        The first two are described in the section called 'Global Parameters' 
in the documentation
        The third one is described in 'Core Functions' (In v2.4, they are items 
45 and 46)
        The fourth is documented in the RR module notes

        John Quick
        Smartvox Limited


        > From: James Hogbin <[email protected]> 
        > Sent: 18 May 2020 17:24
        > To: john quick <[email protected]>; OpenSIPS users mailling 
list <[email protected]>
        > Subject: Re: [OpenSIPS-Users] Running OpenSIPS on same box as 
Asterisk/FreeSwitch
        >
        > I thought I had just done some bad config. I have almost exactly the 
same thing.
        >
        > I have Freeswitch And Opensips on Azure VM’s
        >
        > Freeswitch = 10.0.0.4 + External IP
        > Opensips = 10.0.0.5 + External IP
        >
        > Both are configured to use the external addresses
        >
        > Freeswitch will start the conversation on its external Gateway IP 
address with the Opensips external IP address
        >
        > However the moment I put the Record_Route in the message to Teams 
Freeswitch starts using the local 10.x.x.x. address on opensips rather than the 
external address for ACK and BYE which rogers the whole thing up.
        >
        > I’m sure there is probably some way to fix it in the opensips plan as 
the dialog/transaction ID’s are still there but it’s beyond me.
        >
        > James
        > James Hogbin 
        > Director 


        _______________________________________________
        Users mailing list
        [email protected]
        http://lists.opensips.org/cgi-bin/mailman/listinfo/users




_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to