2014-05-12 52 views
0

我正在使用Mobicents Sip Servlets 3.0.0-SNAPSHOT。我在DAR中配置了兩個servlet;一個用於檢查是否正在嘗試第三方註冊,另一個用於執行實際註冊。我發現當REGISTER到達時,它被傳遞給第一個servlet(BlockerApp);但是當該servlet完成並代理下一個時,第二個servlet(RegApp)不會被調用。相反,再次調用第一個servlet,並將路由指令設置爲NEW。Sip Servlets - 控制不傳遞給鏈中的下一個Servlet

任何想法?我錯過了什麼嗎?

DAR配置:

REGISTER =( 「RegApp」, 「DAR \:從」, 「始發」, 「」, 「NO_ROUTE」, 「1」),( 「BlockerApp」,「DAR \:從」, 「始發」, 「」, 「NO_ROUTE」, 「0」)

第一個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(); 
     } 

    } 

} 

第二個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(); 
    } 

} 

登錄:

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:[email protected]:5090;rinstance=664938eda63f586d;transport=udp> 
To: "110" <sip:[email protected]:5080> 
From: "110" <sip:[email protected]: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:[email protected]: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:[email protected]:5090;rinstance=664938eda63f586d;transport=udp> 
To: "110" <sip:[email protected]:5080> 
From: "110" <sip:[email protected]: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:[email protected]: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:[email protected]:5090;rinstance=664938eda63f586d;transport=udp> 
To: "110" <sip:[email protected]:5080> 
From: "110" <sip:[email protected]: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:[email protected]: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:[email protected]: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:[email protected]: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:[email protected]: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:[email protected]: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:[email protected]:5080>;tag=52ca933d 
Content-Length: 0 

]]> 
</message> 

回答

1

我現在明白爲什麼沒有爲我工作。使用DAR的SIP Servlet鏈接僅適用於使用INVITE,SUBSCRIBE,NOTIFY等對話框的方法。我嘗試使用DAR與處理INVITE的多servlet應用程序,並且它按預期工作。

1

REGISTER的應用程序路由現在已修復在最新的git中HEAD