I have prepared request which is as follows:
REGISTER sip:xxx.xxx.xxx.xxx SIP/2.0
Call-ID: cb3a691495487eabc2ca2a5ea1799a7a@192.168.174.1
CSeq: 1 REGISTER
From: <sip:Santanu@xxx.xxx.xxx.xxx>;tag=textclientv1.0
To: <sip:Santanu@xxx.xxx.xxx.xxx>
Max-Forwards: 70
Via: SIP/2.0/TCP 192.168.174.1:5060
Contact: <sip:Santanu@192.168.174.1;transport=tcp>
Content-Length: 0
At
inviteTid = sipProvider.getNewClientTransaction(request);
I am getting null exception.
My code is as follows:
public void register() throws NullPointerException{
Object logger;
try {
cseq++;
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = this.headerFactory.createViaHeader(this.ip,
this.port, "tcp", null);
viaHeaders.add(viaHeader);
// The "Max-Forwards" header.
MaxForwardsHeader maxForwardsHeader = this.headerFactory
.createMaxForwardsHeader(70);
// The "Call-Id" header.
CallIdHeader callIdHeader = this.sipProvider.getNewCallId();
// The "CSeq" header.
@SuppressWarnings("deprecation")
CSeqHeader cSeqHeader = this.headerFactory.createCSeqHeader(cseq,
"REGISTER");
Address fromAddress = addressFactory.createAddress("sip:"
+ username1 + '@' + server);
FromHeader fromHeader = this.headerFactory.createFromHeader(
fromAddress, "textclientv1.0");//String.valueOf(this.tag)//Integer.toString(hashCode())
// The "To" header.
ToHeader toHeader = this.headerFactory.createToHeader(fromAddress,
null);
// this.contactHeader = this.headerFactory
// .createContactHeader(contactAddress);
request = this.messageFactory.createRequest("REGISTER sip:"
+ server + " SIP/2.0\r\n\r\n");
request.addHeader(callIdHeader);
request.addHeader(cSeqHeader);
request.addHeader(fromHeader);
request.addHeader(toHeader);
request.addHeader(maxForwardsHeader);
request.addHeader(viaHeader);
request.addHeader(contactHeader);
//Response response=this.messageFactory.createResponse(200, request);
if (resp != null) {
boolean retry = true;
AuthorizationHeader authHeader = Utils.makeAuthHeader(headerFactory, resp,
request, username1, password);
request.addHeader(authHeader);
}
System.out.println(""+ request);
inviteTid = sipProvider.getNewClientTransaction(request);
// send the request out.
inviteTid.sendRequest();
this.dialog = inviteTid.getDialog();
// Send the request statelessly through the SIP provider.
// this.sipProvider.sendRequest(request);
// Display the message in the text area.
//debug("Request sent:\n" + request.toString() + "\n\n");
} catch (Exception e) {
// If an error occurred, display the error.
e.printStackTrace();
//debug("Request sent failed: " + e.getMessage() + "\n");
}
}
That's a very unusual way to create a request. My guess here is that you have "\r\n\r\n", which creates an empty line which terminates parsing of the SIP message. But this way of creating the message is not good anyway, you should let the constructor do its job for proper whitespaces and formatting with the protocol details and validated URIs.
I suggest you look at this example https://github.com/usnistgov/jsip/blob/master/src/examples/simplecallsetup/Shootist.java#L318
Otherwise please post here the std output and debug logs.