[OpenSIPS-Users] Public IP dispatcher and private ip presence servers

Bogdan-Andrei Iancu bogdan at opensips.org
Thu Oct 20 14:28:51 CEST 2016


Hi Surya,

Could post somewhere a complete capture of the SUBSCRIBE + NOTIFY, taken 
from OpenSIPS ?

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 20.10.2016 07:39, surya wrote:
> Hi Bogdan,
>
> Thanks for the answer. I tried the record-route but that created loop
> between dispatcher and the presence server, I started getting too many hops
> in both. Sample this:
>
> /Oct 19 23:07:40 [73] DBG:core:build_res_buf_from_sip_res: copied size:
> orig:90, new: 26, rest: 362 msg=
> SIP/2.0 483 To Many HopsVia: SIP/2.0/UDP
> 172.17.0.5:5060;branch=z9hG4bK79ea.2ab64515.0
> Via: SIP/2.0/UDP 172.17.0.2:5060;branch=z9hG4bK79ea.1ab64515.0
> Via: SIP/2.0/UDP 172.17.0.5:5060;branch=z9hG4bK79ea.1ab64515.0
> Via: SIP/2.0/UDP 172.17.0.2:5060;branch=z9hG4bK79ea.0ab64515.0
> Via: SIP/2.0/UDP 172.17.0.5:5060;branch=z9hG4bK79ea.0ab64515.0
> To: <sip:service at opensipstest.org>;tag=1
> From:
> <sip:service-1 at opensipstest.org>;tag=80675298202cdedfab05883cddeed060-0467
> CSeq: 1 NOTIFY
> Call-ID: 1-20 at 172.17.0.4
> Server: OpenSIPS (1.8.4-notls (x86_64/linux))
> Content-Length: 0/
>
> here 0.2 is dispatcher, 0.5 is presence server and request comes from 0.4.
>
> The config for dispatcher:
> ---------------------------------------------------------------------------
> route{
>          if ( !mf_process_maxfwd_header("10") )
>          {
>                  send_reply("483","To Many Hops");
>                  exit;
>          };
> #I added this. Need some condition checks??
>        *   if(method=="SUBSCRIBE")
>          {
>               record_route();
>          }*
>          if ( !ds_select_dst("1", "4") ) {
>                  send_reply("500","Unable to route");
>                  exit;
>          }
> forward();
> #       t_relay();
> }
> ---------------------------------------------------------------------------
>
> Config for presence
> ---------------------------------------------------------------------------
> # main request routing logic
>
> route{
>
>
>          if (!mf_process_maxfwd_header("10")) {
>                  sl_send_reply("483","Too Many Hops");
>                  exit;
>          }
>
>          if (has_totag()) {
>                  # sequential request withing a dialog should
>                  # take the path determined by record-routing
>                  if (loose_route()) {
>
>                          if (is_method("BYE")) {
>                                  setflag(1); # do accounting ...
>                                  setflag(3); # ... even if the transaction
> fails
>                          } else if (is_method("INVITE")) {
>                                  # even if in most of the cases is useless,
> do RR for
>                                  # re-INVITEs alos, as some buggy clients do
> change route set
>                                  # during the dialog.
>                                  record_route();
>                          }
>
>
>
>                          # route it out to whatever destination was set by
> loose_route()
>                          # in $du (destination URI).
>                          route(1);
>                  } else {
>                          if (is_method("SUBSCRIBE") && $rd ==
> "172.17.0.5:5060") { # CUSTOMIZE ME
>                                  # in-dialog subscribe requests
>                                  route(2);
>                                  exit;
>                          }
>                          if ( is_method("ACK") ) {
>                                  if ( t_check_trans() ) {
>                                          # non loose-route, but stateful ACK;
> must be an ACK after
>                                          # a 487 or e.g. 404 from upstream
> server
>                                          t_relay();
>                                          exit;
>                                  } else {
>                                          # ACK without matching transaction
> ->
>                                          # ignore and discard
>                                          exit;
>                                  }
>                          }
>                          sl_send_reply("404","Not here");
>                  }
>                  exit;
>          }
>
>          # CANCEL processing
>          if (is_method("CANCEL"))
>          {
>                  if (t_check_trans())
>                          t_relay();
>                  exit;
>          }
>
>          t_check_trans();
>
>          if ( !(is_method("REGISTER")  ) ) {
>
>                  if (from_uri==myself)
>
>                  {
>
>                  } else {
>                          # if caller is not local, then called number must be
> local
>
>                          if (!uri==myself) {
>                                  send_reply("403","Rely forbidden");
>                                  exit;
>                          }
>                  }
>
>          }
>
>          # preloaded route checking
>          if (loose_route()) {
>                  xlog("L_ERR",
>                  "Attempt to route with preloaded Route's
> [$fu/$tu/$ru/$ci]");
>                  if (!is_method("ACK"))
>                          sl_send_reply("403","Preload Route denied");
>                  exit;
>          }
>
>          # record routing
>          if (!is_method("REGISTER|MESSAGE"))
>                  record_route();
>
>          # account only INVITEs
>          if (is_method("INVITE")) {
>
>                  setflag(1); # do accounting
>          }
>
>
>          if (!uri==myself) {
>                  append_hf("P-hint: outbound\r\n");
>
>                  route(1);
>          }
>
>          # requests for my domain
>
>          if( is_method("PUBLISH|SUBSCRIBE"))
>                          route(2);
>
>          if (is_method("REGISTER"))
>          {
>
>
>                  if ( proto==TCP ||  0 ) setflag(7);
>
>                  if (!save("location"))
>                          sl_reply_error();
>
>                  exit;
>          }
>
>          if ($rU==NULL) {
>                  # request with no Username in RURI
>                  sl_send_reply("484","Address Incomplete");
>                  exit;
>          }
>
>
>
>
>
>
>
>          # do lookup with method filtering
>          if (!lookup("location","m")) {
>
>
>                  t_newtran();
>                  t_reply("404", "Not Found");
>                  exit;
>          }
>
>
>
>          # when routing via usrloc, log the missed calls also
>          setflag(2);
>          route(1);
> }
>
>
> route[1] {
>          # for INVITEs enable some additional helper routes
>          if (is_method("INVITE")) {
>
>
>
>                  t_on_branch("2");
>                  t_on_reply("2");
>                  t_on_failure("1");
>          }
>
>
>
>          if (!t_relay()) {
>                  send_reply("500","Internal Error");
>          };
>          exit;
> }
>
>
> # Presence route
> route[2]
> {
>          if (!t_newtran())
>          {
>                  sl_reply_error();
>                  exit;
>          }
>
>          if(is_method("PUBLISH"))
>          {
>                  force_rport();
>                  handle_publish();
>          }
>          else
>          if( is_method("SUBSCRIBE"))
>          {
>                  force_rport();
>                  handle_subscribe();
>          }
>
>          exit;
> }
>
>
> branch_route[2] {
>          xlog("new branch at $ru\n");
> }
>
>
> onreply_route[2] {
>
>          xlog("incoming reply\n");
> }
>
>
> failure_route[1] {
>          if (t_was_cancelled()) {
>                  exit;
>          }
>
>          # uncomment the following lines if you want to block client
>          # redirect based on 3xx replies.
>          ##if (t_check_status("3[0-9][0-9]")) {
>          ##t_reply("404","Not found");
>          ##      exit;
>          ##}
>
>
> }
> ---------------------------------------------------------------------------
>
> The config of presence is as generated from the tool, I just added
> force_rport().
>
> I do not have any idea why this is happening.
>
> Appreciate your help again.
>
> Thanks,
> Surya
>
>
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Public-IP-dispatcher-and-private-ip-presence-servers-tp7604684p7604701.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>




More information about the Users mailing list