使用 wss 时 Restcomm SipServlet UAC 丢失联系人
Restcomm SipServlet UAC missing contact when using wss
我正在尝试在收到这样的邀请时触发注册请求:
SipURI fromToURI = sipFactory.createSipURI(userName, domainName);
//using the invite request to make a register request
SipServletRequest sipServletRequest = sipFactory.createRequest(request.getApplicationSession(), "REGISTER", fromToURI, fromToURI);
sipServletRequest.setHeader("Expires", "3600");
sipServletRequest.setHeader("User-Agent", "mobicentsWSSclient");
SipURI requestURI = sipFactory.createSipURI("myroutablewssproxy.com", domainName);
//.setPort();
requestURI.setTransportParam("wss");
requestURI.setPort(8443);
try {
Parameterable parameterable = sipServletRequest.getParameterableHeader("Contact");
parameterable.setParameter("expires", "0");
} catch (ServletParseException e1) {
logger.error("Impossible to set the expires on the contact header",e1);
}
try {
sipServletRequest.setRequestURI(requestURI);
sipServletRequest.send();
} catch (IOException e) {
logger.error("An unexpected exception occured while sending the REGISTER request",e);
}
但我在尝试访问联系人 header 时收到空指针异常。如果我不尝试访问联系人 header,则注册请求完全缺少联系人 header,因此注册尝试失败。有没有办法访问 servlet 上下文并在此注册请求中使用它的联系信息?
来自 SIP Servlets 规范第 4.1.3 节
Contact header 是一个系统头,这意味着它由容器管理,不能被应用程序修改或设置,但以下消息除外:
1.注册请求和响应
2. 3xx 响应
3. 485 条回复
4. 200/OPTIONS 回复
因此,在这种情况下,您的应用程序负责在 REGISTER 请求和响应中设置 Contact Header。
我正在尝试在收到这样的邀请时触发注册请求:
SipURI fromToURI = sipFactory.createSipURI(userName, domainName);
//using the invite request to make a register request
SipServletRequest sipServletRequest = sipFactory.createRequest(request.getApplicationSession(), "REGISTER", fromToURI, fromToURI);
sipServletRequest.setHeader("Expires", "3600");
sipServletRequest.setHeader("User-Agent", "mobicentsWSSclient");
SipURI requestURI = sipFactory.createSipURI("myroutablewssproxy.com", domainName);
//.setPort();
requestURI.setTransportParam("wss");
requestURI.setPort(8443);
try {
Parameterable parameterable = sipServletRequest.getParameterableHeader("Contact");
parameterable.setParameter("expires", "0");
} catch (ServletParseException e1) {
logger.error("Impossible to set the expires on the contact header",e1);
}
try {
sipServletRequest.setRequestURI(requestURI);
sipServletRequest.send();
} catch (IOException e) {
logger.error("An unexpected exception occured while sending the REGISTER request",e);
}
但我在尝试访问联系人 header 时收到空指针异常。如果我不尝试访问联系人 header,则注册请求完全缺少联系人 header,因此注册尝试失败。有没有办法访问 servlet 上下文并在此注册请求中使用它的联系信息?
来自 SIP Servlets 规范第 4.1.3 节 Contact header 是一个系统头,这意味着它由容器管理,不能被应用程序修改或设置,但以下消息除外: 1.注册请求和响应 2. 3xx 响应 3. 485 条回复 4. 200/OPTIONS 回复
因此,在这种情况下,您的应用程序负责在 REGISTER 请求和响应中设置 Contact Header。