1

您好我目前正在使用restcomm-sip-servlets-4.0.75-apache-tomcat-8.0.26。我在取消来自 http 请求线程的正在进行的请求时遇到问题。我注意到这个问题似乎只发生在我创建一个带有 auth 标头的新请求时,如下所示:

    AuthInfo authInfo = sipFactory.createAuthInfo();
            authInfo.addAuthInfo(
                    response.getStatus(), 
                    realm,myauth,password); 


            SipServletRequest challengeRequest = response.getSession().createRequest(
                    response.getRequest().getMethod());
        (String)session.getAttribute("FirstPartyContent");
            if(session.getAttribute("FirstPartyContent") !=null){
                challengeRequest.setContent(session.getAttribute("FirstPartyContent"),(String) session.getAttribute("FirstPartyContentType"));
            }
            challengeRequest.addAuthHeader(response, authInfo);

            challengeRequest.getFrom().setDisplayName(auth.getDisplayName());

            session.removeAttribute("original");
            session.setAttribute("original", challengeRequest);
            challengeRequest.send(); 

当请求通过 http 接口进入时,我会像这样查找 SipApplicationSession:

        SipSessionsUtil sipSessionsUtil = 
                (SipSessionsUtil) session.getServletContext().
                    getAttribute("javax.servlet.sip.SipSessionsUtil");
     logger.info("found servlet contxt for sipsession util");

     SipApplicationSession tobecancelledsess = sipSessionsUtil.getApplicationSessionById(sessionapplicationID); 

然后我从存储的会话请求中创建一个取消请求,如下所示:

SipServletRequest req = (SipServletRequest)tobecancelledsess.getAttribute("original"); 请求 = req.createCancel();

尽管远程服务器使用 to-tag 临时响应我得到:

2017-04-28 16:26:04,470 调试 [SipServletMessageImpl] (http-bio-8443-exec-1) 事务 null tr​​ansactionId = null tr​​ansactionType false 2017-04-28 16:26:04,470 调试 [SipServletMessageImpl] (http-bio -8443-exec-1) 事务 null tr​​ansactionId = null tr​​ansactionType false java.lang.IllegalStateException:未找到客户端事务!在 org.example.servlet.sip 的 org.example.servlet.sip.CallContainer.CancelSession(CallContainer.java:319) 的 org.mobicents.servlet.sip.message.SipServletRequestImpl.createCancel(SipServletRequestImpl.java:258) 处为空。 CallContainer.CheckCancel(CallContainer.java:274) at org.example.servlet.sip.SimpleWebServlet.doPut(SimpleWebServlet.java:360) at org.example.servlet.sip.SimpleWebServlet.service(SimpleWebServlet.java:149) at javax .servlet.http.HttpServlet.service(HttpServlet.java:729) 在 org。

我注意到当我取消来自 servlet 类的请求时,我没有这个问题。

4

1 回答 1

1

我发现像这样在响应中设置上下文属性可以解决我的问题:

if (resp.getStatus() == SipServletResponse.SC_RINGING){
            SipSession session = resp.getSession();
 resp.getSession().getServletContext().setAttribute("ringing",true);
}

然后我像这样抓住会话上下文

SipServletRequest req = (SipServletRequest)tobecancelledsess.getAttribute("original");
    Boolean ringed =  (Boolean ) tobecancelledsess.getServletContext().getAttribute("ringing");
    if(ringed == Boolean.True)
     drequest = req.createCancel();

最终您需要使用 send() 发送取消请求;

于 2017-04-29T00:57:20.727 回答