OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Matt Stockton
Hi all,

I am currently using OpenSips as an inbound loadbalancer and an outbound proxy. It does the following for me:
- Receives calls from my provider and balances them across several Freeswitch nodes. 
- Accepts calls from the several Freeswitch nodes, and dispatches them to various providers

Note that I do not have to support any registration, just invites as mentioned above. 
I am using the load_balancer module to balance the inbound calls to OpenSips, and I am using the drouting module to route the calls initiated at the Freeswitches and sent through OpenSips. 

Most things seem to be working smoothly, except for one issue. When I make calls out of the Freeswitch -> OpenSips -> Provider -> PSTN, sometimes the OpenSips is not properly routing the BYE message when the call is hung up.

I can see the BYE message coming in from the provider, but it looks like sometimes they have changed the BYE header.

When it comes into me like the following, it is working fine for me, OpenSips forwards the BYE on to the correct Freeswitch node, which is located at .223
BYE [hidden email];transport=udp;gw=opensips_0 SIP/2.0

However, sometimes it comes in like this:
BYE sip:gw+opensips_0@PUBLIC_IP_OF_OPENSIPS:47013;transport=udp;gw=opensips_0 SIP/2.0

When this occurs, OpenSips seems to try to forward the BYE back to itself, using the PUBLIC_IP_OF_OPENSIPS.

I understand that I must be doing something wrong if I am exposing the private IPs of my systems externally, but I'm not understanding why the BYE message is sent differently by the provider without any changes and it is intermittently happening. 

Any advice here? I am a newbie to OpenSips, so apologies if these are real basic questions.

Here is my route block, FYI:

route{
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }

        if (!has_totag()) {
                # initial request
                record_route();
        }
        else {
                # sequential request - obey the indicated route
                loose_route();
                t_relay();
                exit;
        }

        # handle cancel and re-transmissions
        if ( is_method("CANCEL") ) {
                if ( t_check_trans() )
                        t_relay();
                exit;
        }

        if (is_method("INVITE")) {
                # This is the outgoing route to the pstn if it is coming from internal
                if(src_ip =~ "^10\.10\..*"){
                        setflag(1); # do accounting
                        route(pstn_outgoing); # Call our dynamic route.
                } else {
                        # This is loadbalancing the incoming calls from the pstn        
                        setflag(1);
                        route(lb_incoming);
                }
        }else {
                send_reply("405","Method Not Allowed");
                exit;
        }

        # route the request
        if (!t_relay()) {
                sl_reply_error();
        }
}



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

ddgiants
Matt,
Sounds like you may not be topology hiding the 200OKs. Some/most SIP devices/SBC's etc will send a BYE to the ip address in the o(owner) line of the SDP of the 200OK. Some devices do not and send BYE to the initator/proxy they are configured for. The 200OK will have o and c. O is the owner, meaning signaling owner and C is the connection IP as in where to send the actual RTP. I use the below to change the o portion of the SDP in 200 OKs and works for me. Give it a try and let me know.

onreply_route[1] {
  setflag(1);
  if(t_check_status("200")) {
    if(search("Content-type: application/sdp")) {
      fix_nated_sdp("8", "x.x.x.x");
    }
  }
}

DD
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Matt Stockton
I added the following to my config:

onreply_route[pstn_outgoing] {
   setflag(1);
   if(t_check_status("200")) {
     if(search("Content-type: application/sdp")) {
        fix_nated_sdp("8", "x.x.x.x");
     }
   }
}

And the only thing that seemed to have changed in the SIP signalling is, when my provider sends SIP 200 OK to OpenSips, OpenSips is just re-writing the OK Content before sending onto Freeswitch. It doesn't look like any messages have changed that are going from OpenSips to the provider, and the provider is still sending the BYE message with the Contact Header intermittently to the different IPs as I described. Any more thoughts on this? 

My end goal is to simply have the same OpenSips act as both an inbound proxy and outbound proxy, with no registration requirements. If there is an easier way to do this with OpenSips, please let me know. I've looked around and checked out all the referenced tutorials on the site w/r/t load balancing and routing

v=0
o=Sonus_UAC 14270 3732 IN IP4 x.x.x.x
s=SIP Media Capabilities
c=IN IP4 67.231.0.110
t=0 0
m=audio 25620 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
a=maxptime:20
a=oldmediaip:ACTUAL_IP



On Thu, Nov 10, 2011 at 7:17 PM, ddgiants <[hidden email]> wrote:
Matt,
Sounds like you may not be topology hiding the 200OKs. Some/most SIP
devices/SBC's etc will send a BYE to the ip address in the o(owner) line of
the SDP of the 200OK. Some devices do not and send BYE to the initator/proxy
they are configured for. The 200OK will have o and c. O is the owner,
meaning signaling owner and C is the connection IP as in where to send the
actual RTP. I use the below to change the o portion of the SDP in 200 OKs
and works for me. Give it a try and let me know.

onreply_route[1] {
 setflag(1);
 if(t_check_status("200")) {
   if(search("Content-type: application/sdp")) {
     fix_nated_sdp("8", "x.x.x.x");
   }
 }
}

DD

--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSips-as-an-inbound-loadbalancer-and-outbound-proxy-issue-with-routing-BYES-tp6984017p6984067.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

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


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Matt Stockton
After doing some reading, thinking that I may be able to solve my problem using the dialog module and fix_route_dialog(). Since the Contact Header is being re-written by the Provider, will fix_route_dialog() change it on the way in to the appropriate value in the dialog, causing the message to be forwarded correctly? The code for what I'm thinking is below. Unfortunately, the issue is so intermittent that I have not been able to re-produce the case of the Provider re-writing the Contact Header since I started trying this modification. Does anyone know if this strategy will work?

       if (!has_totag()) {
                create_dialog();
                # initial request
                record_route();
        }
        else {
                # sequential request - obey the indicated route
                loose_route();

                if ($DLG_status!=NULL) {
                   if (!validate_dialog()) {
                      fix_route_dialog();
                   }
                }

                t_relay();
                exit;
        }


On Fri, Nov 11, 2011 at 9:23 AM, Matt Stockton <[hidden email]> wrote:
I added the following to my config:

onreply_route[pstn_outgoing] {
   setflag(1);
   if(t_check_status("200")) {
     if(search("Content-type: application/sdp")) {
        fix_nated_sdp("8", "x.x.x.x");
     }
   }
}

And the only thing that seemed to have changed in the SIP signalling is, when my provider sends SIP 200 OK to OpenSips, OpenSips is just re-writing the OK Content before sending onto Freeswitch. It doesn't look like any messages have changed that are going from OpenSips to the provider, and the provider is still sending the BYE message with the Contact Header intermittently to the different IPs as I described. Any more thoughts on this? 

My end goal is to simply have the same OpenSips act as both an inbound proxy and outbound proxy, with no registration requirements. If there is an easier way to do this with OpenSips, please let me know. I've looked around and checked out all the referenced tutorials on the site w/r/t load balancing and routing

v=0
o=Sonus_UAC 14270 3732 IN IP4 x.x.x.x
s=SIP Media Capabilities
c=IN IP4 67.231.0.110
t=0 0
m=audio 25620 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
a=maxptime:20
a=oldmediaip:ACTUAL_IP



On Thu, Nov 10, 2011 at 7:17 PM, ddgiants <[hidden email]> wrote:
Matt,
Sounds like you may not be topology hiding the 200OKs. Some/most SIP
devices/SBC's etc will send a BYE to the ip address in the o(owner) line of
the SDP of the 200OK. Some devices do not and send BYE to the initator/proxy
they are configured for. The 200OK will have o and c. O is the owner,
meaning signaling owner and C is the connection IP as in where to send the
actual RTP. I use the below to change the o portion of the SDP in 200 OKs
and works for me. Give it a try and let me know.

onreply_route[1] {
 setflag(1);
 if(t_check_status("200")) {
   if(search("Content-type: application/sdp")) {
     fix_nated_sdp("8", "x.x.x.x");
   }
 }
}

DD

--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSips-as-an-inbound-loadbalancer-and-outbound-proxy-issue-with-routing-BYES-tp6984017p6984067.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

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



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Vlad Paiu
Hello,

fix_route_dialog() uses the information from the Contact of the 200 OK. So if that is ok, you can use fix_route_dialog() to fix the bogus BYE messages.

Regards,
Vlad Paiu
OpenSIPS Developer

On 11/12/2011 06:22 PM, Matt Stockton wrote:
After doing some reading, thinking that I may be able to solve my problem using the dialog module and fix_route_dialog(). Since the Contact Header is being re-written by the Provider, will fix_route_dialog() change it on the way in to the appropriate value in the dialog, causing the message to be forwarded correctly? The code for what I'm thinking is below. Unfortunately, the issue is so intermittent that I have not been able to re-produce the case of the Provider re-writing the Contact Header since I started trying this modification. Does anyone know if this strategy will work?

       if (!has_totag()) {
                create_dialog();
                # initial request
                record_route();
        }
        else {
                # sequential request - obey the indicated route
                loose_route();

                if ($DLG_status!=NULL) {
                   if (!validate_dialog()) {
                      fix_route_dialog();
                   }
                }

                t_relay();
                exit;
        }


On Fri, Nov 11, 2011 at 9:23 AM, Matt Stockton <[hidden email]> wrote:
I added the following to my config:

onreply_route[pstn_outgoing] {
   setflag(1);
   if(t_check_status("200")) {
     if(search("Content-type: application/sdp")) {
        fix_nated_sdp("8", "x.x.x.x");
     }
   }
}

And the only thing that seemed to have changed in the SIP signalling is, when my provider sends SIP 200 OK to OpenSips, OpenSips is just re-writing the OK Content before sending onto Freeswitch. It doesn't look like any messages have changed that are going from OpenSips to the provider, and the provider is still sending the BYE message with the Contact Header intermittently to the different IPs as I described. Any more thoughts on this? 

My end goal is to simply have the same OpenSips act as both an inbound proxy and outbound proxy, with no registration requirements. If there is an easier way to do this with OpenSips, please let me know. I've looked around and checked out all the referenced tutorials on the site w/r/t load balancing and routing

v=0
o=Sonus_UAC 14270 3732 IN IP4 x.x.x.x
s=SIP Media Capabilities
c=IN IP4 67.231.0.110
t=0 0
m=audio 25620 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
a=maxptime:20
a=oldmediaip:ACTUAL_IP



On Thu, Nov 10, 2011 at 7:17 PM, ddgiants <[hidden email]> wrote:
Matt,
Sounds like you may not be topology hiding the 200OKs. Some/most SIP
devices/SBC's etc will send a BYE to the ip address in the o(owner) line of
the SDP of the 200OK. Some devices do not and send BYE to the initator/proxy
they are configured for. The 200OK will have o and c. O is the owner,
meaning signaling owner and C is the connection IP as in where to send the
actual RTP. I use the below to change the o portion of the SDP in 200 OKs
and works for me. Give it a try and let me know.

onreply_route[1] {
 setflag(1);
 if(t_check_status("200")) {
   if(search("Content-type: application/sdp")) {
     fix_nated_sdp("8", "x.x.x.x");
   }
 }
}

DD

--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSips-as-an-inbound-loadbalancer-and-outbound-proxy-issue-with-routing-BYES-tp6984017p6984067.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

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


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

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Matt Stockton
Hi,

This is occurring for outbound invites from my Freeswitch (I have FS -> OpenSips -> Provider).  FS sends the invite through OpenSips. The only 200 OK I see in the entire SIP trace on the OpenSips box with a Contact header contains the contact of the number I am trying to call from FS. The issue happens when the BYE is trying to be routed back to the FS from the Provider --- so I think, If I'm reading correctly, fix_route_dialog() will not work for what I'm trying to do?

Thanks, your help is appreciated.

On Mon, Nov 14, 2011 at 3:10 AM, Vlad Paiu <[hidden email]> wrote:
Hello,

fix_route_dialog() uses the information from the Contact of the 200 OK. So if that is ok, you can use fix_route_dialog() to fix the bogus BYE messages.

Regards,
Vlad Paiu
OpenSIPS Developer

On 11/12/2011 06:22 PM, Matt Stockton wrote:
After doing some reading, thinking that I may be able to solve my problem using the dialog module and fix_route_dialog(). Since the Contact Header is being re-written by the Provider, will fix_route_dialog() change it on the way in to the appropriate value in the dialog, causing the message to be forwarded correctly? The code for what I'm thinking is below. Unfortunately, the issue is so intermittent that I have not been able to re-produce the case of the Provider re-writing the Contact Header since I started trying this modification. Does anyone know if this strategy will work?

       if (!has_totag()) {
                create_dialog();
                # initial request
                record_route();
        }
        else {
                # sequential request - obey the indicated route
                loose_route();

                if ($DLG_status!=NULL) {
                   if (!validate_dialog()) {
                      fix_route_dialog();
                   }
                }

                t_relay();
                exit;
        }


On Fri, Nov 11, 2011 at 9:23 AM, Matt Stockton <[hidden email]> wrote:
I added the following to my config:

onreply_route[pstn_outgoing] {
   setflag(1);
   if(t_check_status("200")) {
     if(search("Content-type: application/sdp")) {
        fix_nated_sdp("8", "x.x.x.x");
     }
   }
}

And the only thing that seemed to have changed in the SIP signalling is, when my provider sends SIP 200 OK to OpenSips, OpenSips is just re-writing the OK Content before sending onto Freeswitch. It doesn't look like any messages have changed that are going from OpenSips to the provider, and the provider is still sending the BYE message with the Contact Header intermittently to the different IPs as I described. Any more thoughts on this? 

My end goal is to simply have the same OpenSips act as both an inbound proxy and outbound proxy, with no registration requirements. If there is an easier way to do this with OpenSips, please let me know. I've looked around and checked out all the referenced tutorials on the site w/r/t load balancing and routing

v=0
o=Sonus_UAC 14270 3732 IN IP4 x.x.x.x
s=SIP Media Capabilities
c=IN IP4 67.231.0.110
t=0 0
m=audio 25620 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
a=maxptime:20
a=oldmediaip:ACTUAL_IP



On Thu, Nov 10, 2011 at 7:17 PM, ddgiants <[hidden email]> wrote:
Matt,
Sounds like you may not be topology hiding the 200OKs. Some/most SIP
devices/SBC's etc will send a BYE to the ip address in the o(owner) line of
the SDP of the 200OK. Some devices do not and send BYE to the initator/proxy
they are configured for. The 200OK will have o and c. O is the owner,
meaning signaling owner and C is the connection IP as in where to send the
actual RTP. I use the below to change the o portion of the SDP in 200 OKs
and works for me. Give it a try and let me know.

onreply_route[1] {
 setflag(1);
 if(t_check_status("200")) {
   if(search("Content-type: application/sdp")) {
     fix_nated_sdp("8", "x.x.x.x");
   }
 }
}

DD

--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSips-as-an-inbound-loadbalancer-and-outbound-proxy-issue-with-routing-BYES-tp6984017p6984067.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

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


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

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



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Francjos
In reply to this post by Matt Stockton
Sorry, i'm not going to answer your question, but, since i'm also using Opensips as an inbound loadbalancer and outbound proxy, i would like to ask how did you configure Opensips and freeswitch, because, me, when i try to call my number (that i got from my privider), the number is unreachable or busy.
can you tell me the steps you ging through in order incoming calls to be working?
Thank you
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

aqsyounas

Hi, Francjos.
You can add me on skype i can help you get this done.
ID: aqsyounas

On Apr 12, 2016 4:51 PM, "Francjos" <[hidden email]> wrote:
Sorry, i'm not going to answer your question, but, since i'm also using
Opensips as an inbound loadbalancer and outbound proxy, i would like to ask
how did you configure Opensips and freeswitch, because, me, when i try to
call my number (that i got from my privider), the number is unreachable or
busy.
can you tell me the steps you ging through in order incoming calls to be
working?
Thank you



--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSips-as-an-inbound-loadbalancer-and-outbound-proxy-issue-with-routing-BYES-tp6984017p7602595.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

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

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Francjos
Thank you Younas
I sent an invitation on skype,  but i had two persons with same ID, one Aqs Younas and another aqs younas. Let's me know when you get the invitation.
Reply | Threaded
Open this post in threaded view
|

Re: OpenSips as an inbound loadbalancer and outbound proxy - issue with routing BYES

Francjos
In reply to this post by aqsyounas
Hello Younas,
I sent you the invitation on skype,i'm waiting for your reply. I still have problems with the incoming call throught opensips.
Thank you for your attention.