Сервлеты Sip - контроль не передан следующему сервлету в цепочке
Я работаю с Mobicents Sip Servlets 3.0.0-SNAPSHOT. У меня есть два сервлета, настроенных в DAR; один для проверки, если попытка регистрации третьей стороны, и второй для выполнения фактической регистрации. Я обнаружил, что когда прибывает REGISTER, он передается первому сервлету (BlockerApp); но когда этот сервлет завершает работу и передает следующий, этот второй сервлет (RegApp) не вызывается. Вместо этого первый сервлет вызывается снова с директивой маршрутизации, установленной на NEW.
Есть идеи? Я что-то пропустил?
Конфигурация DAR:
REGISTER = ("RegApp", "ДАР \: С", "составляемых","","NO_ROUTE","1"),("BlockerApp","ДАР \: С", "составляемых","","NO_ROUTE","0")
Первый сервлет:
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();
}
}
}
Второй сервлет:
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();
}
}
Журнал:
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>
2 ответа
Маршрутизация приложений для REGISTER теперь исправлена в последней версии git HEAD
Теперь я понимаю, почему это не работает для меня. Цепочка SIP-сервлетов с использованием DAR работает только с методами, в которых диалоговое окно имеет вид INVITE, SUBSCRIBE, NOTIFY и т. Д. Я попытался использовать DAR с приложением с несколькими сервлетами, обрабатывающим INVITE, и он работает, как и ожидалось.