0

I am working with Mobicents Sip Servlets 3.0.0-SNAPSHOT. I have two servlets configured in the DAR; one to check to see if a third party registration is being attempted, and a second to perform the actual registration. I am finding that when the REGISTER arrives, it is passed to the first servlet (BlockerApp); but when that servlet completes and proxies to the next, that the second servlet (RegApp) is not called. Instead, the first servlet is called again, with the routing directive set to NEW.

Any ideas? Am I missing something?

DAR configuration:

REGISTER=("RegApp","DAR\:From","ORIGINATING","","NO_ROUTE","1"),("BlockerApp","DAR\:From","ORIGINATING","","NO_ROUTE","0")

First Servlet:

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.sip.Proxy;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
import javax.servlet.sip.SipURI;

import org.apache.log4j.Logger;

@javax.servlet.sip.annotation.SipServlet(name = "Blocker", loadOnStartup = 1)
public class Blocker extends SipServlet {
    private static final long serialVersionUID = 1L;
    private static Logger logger = Logger.getLogger(Blocker.class);
    private static final String LOOP_CHECK_HEADER = "X-looping";

    @Override
    protected void doRegister(SipServletRequest req) throws ServletException,
            IOException {

        logger.info("######################################################");
        logger.info("Blocker");
        logger.info("region:" + req.getRegion());
        logger.info("routing directive:" + req.getRoutingDirective());
        logger.info("subscriber uri:" + req.getSubscriberURI());
        logger.info("popped route:" + req.getPoppedRoute());
        logger.info("######################################################");

        if (req.getHeader(LOOP_CHECK_HEADER) != null
                && !req.getHeader(LOOP_CHECK_HEADER).isEmpty()) {
            SipServletResponse resp = req
                    .createResponse(SipServletResponse.SC_FORBIDDEN);
            resp.send();
            return;
        }
        req.addHeader(LOOP_CHECK_HEADER, "1");

        String toUser = null;
        if (req.getTo().getURI().isSipURI()) {
            toUser = ((SipURI) req.getTo().getURI()).getUser();
        }

        String fromUser = null;
        if (req.getFrom().getURI().isSipURI()) {
            fromUser = ((SipURI) req.getFrom().getURI()).getUser();
        }

        if (toUser != null && fromUser != null && toUser.equals(fromUser)) {
            Proxy proxy = req.getProxy();
            proxy.proxyTo(req.getRequestURI());
        } else {
            SipServletResponse rsp = req.createResponse(
                    SipServletResponse.SC_DECLINE,
                    "No third party registrations accepted");
            rsp.send();
        }

    }

}

Second Servlet:

import java.io.IOException;

import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.sip.Address;
import javax.servlet.sip.SipFactory;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
import javax.servlet.sip.SipURI;

import org.apache.log4j.Logger;

import com.mcleodnet.registrar.business.ContactInformationService;
import com.mcleodnet.registrar.data.ContactUpdate;

@javax.servlet.sip.annotation.SipServlet(name = "Registrar", loadOnStartup = 1)
public class Registrar extends SipServlet {
    private static final long serialVersionUID = 1L;
    private static Logger logger = Logger.getLogger(Registrar.class);

    @EJB(lookup = "java:global/Registrar/RegistrarDatabase/ContactInformationServiceImpl!com.mcleodnet.registrar.business.ContactInformationServiceLocal")
    private ContactInformationService cis;

    @Resource
    SipFactory sipFactory;

    @Override
    protected void doRegister(SipServletRequest req) throws ServletException,
            IOException {

        logger.info("######################################################");
        logger.info("Registrar");
        logger.info("region:" + req.getRegion());
        logger.info("routing directive:" + req.getRoutingDirective());
        logger.info("subscriber uri:" + req.getSubscriberURI());
        logger.info("popped route:" + req.getPoppedRoute());
        logger.info("######################################################");

        SipServletResponse rsp = req.createResponse(SipServletResponse.SC_OK,
                "OK");

        Address contactHeader = req.getAddressHeader("contact");
        String contactUri = contactHeader.getURI().toString();

        String username = null;
        if (req.getTo().getURI().isSipURI()) {
            username = ((SipURI) req.getTo().getURI()).getUser();
        }

        int expires = req.getExpires();
        if (expires == -1) {
            expires = contactHeader.getExpires();
        }

        if (expires == 0) {
            cis.deleteContactInformation(username);
        } else {
            cis.updateContactInformation(username, new ContactUpdate(
                    contactUri, expires));
        }

        rsp.send();
    }

}

Log:

11:56:40,296 INFO  [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) <message
from="192.168.100.125:5090"
to="0.0.0.0:5080"
time="1399921000293"
isSender="false"
transactionId="z9hg4bk-d8754z-7178ee0abc532a51-1---d8754z-"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="REGISTER sip:192.168.100.136:5080 SIP/2.0"
>
<![CDATA[REGISTER sip:192.168.100.136:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
Max-Forwards: 70
Contact: <sip:110@192.168.100.125:5090;rinstance=664938eda63f586d;transport=udp>
To: "110" <sip:110@192.168.100.136:5080>
From: "110" <sip:110@192.168.100.136:5080>;tag=52ca933d
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: X-Lite release 4.5.5  stamp 71236
Content-Length: 0

]]>
</message>

11:56:40,297 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) ######################################################
11:56:40,298 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) Blocker
11:56:40,298 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) region:ORIGINATING
11:56:40,298 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) routing directive:NEW
11:56:40,299 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) subscriber uri:sip:110@192.168.100.136:5080
11:56:40,299 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) popped route:null
11:56:40,299 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) ######################################################
11:56:40,302 INFO  [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) <message
from="192.168.100.136:5080"
to="0.0.0.0:5080"
time="1399921000301"
isSender="false"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="REGISTER sip:192.168.100.136:5080 SIP/2.0"
>
<![CDATA[REGISTER sip:192.168.100.136:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
Max-Forwards: 69
Contact: <sip:110@192.168.100.125:5090;rinstance=664938eda63f586d;transport=udp>
To: "110" <sip:110@192.168.100.136:5080>
From: "110" <sip:110@192.168.100.136:5080>;tag=52ca933d
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: X-Lite release 4.5.5  stamp 71236
X-looping: 1
Content-Length: 0

]]>
</message>

11:56:40,303 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) ######################################################
11:56:40,303 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) Blocker
11:56:40,303 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) region:ORIGINATING
11:56:40,304 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) routing directive:NEW
11:56:40,304 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) subscriber uri:sip:110@192.168.100.136:5080
11:56:40,304 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) popped route:null
11:56:40,304 INFO  [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) ######################################################
11:56:40,305 INFO  [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) <message
from="0.0.0.0:5080"
to="192.168.100.136:5080"
time="1399921000300"
isSender="true"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="REGISTER sip:192.168.100.136:5080 SIP/2.0"
>
<![CDATA[REGISTER sip:192.168.100.136:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
Max-Forwards: 69
Contact: <sip:110@192.168.100.125:5090;rinstance=664938eda63f586d;transport=udp>
To: "110" <sip:110@192.168.100.136:5080>
From: "110" <sip:110@192.168.100.136:5080>;tag=52ca933d
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: X-Lite release 4.5.5  stamp 71236
X-looping: 1
Content-Length: 0

]]>
</message>

11:56:40,307 INFO  [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-5) <message
from="192.168.100.136:5080"
to="0.0.0.0:5080"
time="1399921000307"
isSender="false"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="SIP/2.0 403 Forbidden"
>
<![CDATA[SIP/2.0 403 Forbidden
To: "110" <sip:110@192.168.100.136:5080>;tag=27182159_74a2f52c_f3f49504-2264-4b83-bfe2-48103366fb36
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
CSeq: 1 REGISTER
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
From: "110" <sip:110@192.168.100.136:5080>;tag=52ca933d
Content-Length: 0

]]>
</message>

11:56:40,305 INFO  [org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) Request event dispatched to BlockerApp
11:56:40,308 INFO  [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) <message
from="0.0.0.0:5080"
to="192.168.100.136:5080"
time="1399921000306"
isSender="true"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="SIP/2.0 403 Forbidden"
>
<![CDATA[SIP/2.0 403 Forbidden
To: "110" <sip:110@192.168.100.136:5080>;tag=27182159_74a2f52c_f3f49504-2264-4b83-bfe2-48103366fb36
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
CSeq: 1 REGISTER
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
From: "110" <sip:110@192.168.100.136:5080>;tag=52ca933d
Content-Length: 0

]]>
</message>

11:56:40,308 INFO  [org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) Request event dispatched to BlockerApp
11:56:40,310 INFO  [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-5) <message
from="0.0.0.0:5080"
to="192.168.100.125:5090"
time="1399921000309"
isSender="true"
transactionId="z9hg4bk-d8754z-7178ee0abc532a51-1---d8754z-"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="SIP/2.0 403 Forbidden"
>
<![CDATA[SIP/2.0 403 Forbidden
To: "110" <sip:110@192.168.100.136:5080>;tag=27182159_74a2f52c_f3f49504-2264-4b83-bfe2-48103366fb36
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
CSeq: 1 REGISTER
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
From: "110" <sip:110@192.168.100.136:5080>;tag=52ca933d
Content-Length: 0

]]>
</message>
Ron McLeod
  • 643
  • 7
  • 12

2 Answers2

1

I now understand why is was not working for me. SIP Servlet chaining using the DAR only works with methods which have dialogs usch as INVITE, SUBSCRIBE, NOTIFY, etc. I have tried using DAR with a multi-servlet application handling an INVITE, and it works as expected.

Ron McLeod
  • 643
  • 7
  • 12
1

Application Routing for REGISTER is now fixed in the latest git HEAD

jeand
  • 2,325
  • 14
  • 12