restcommmobicents-sip-servlets

Restcomm SipServlet UAC missing contact when using wss


I am attempting to trigger a registration request when receiving an invite like so:

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);
}

but I am getting a null pointer exception when attempting to access the contact header. If I do not attempt to the access the contact header the registration request is lacking of a contact header entirely and so the registration attempt fails. Is there a way to access the servlet context and utilize it's contact information in this registration request?


Solution

  • From the SIP Servlets specification Section 4.1.3 Contact header is a system header which means that it is managed by the container and cannot be modified or set by the applications except for the following messages: 1. REGISTER requests and responses 2. 3xx responses 3. 485 responses 4. 200/OPTIONS responses

    So in this case your application is responsible for setting the Contact Header on REGISTER requests and responses.