Я подготовил запрос, который выглядит следующим образом:
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
В
inviteTid = sipProvider.getNewClientTransaction(request);
Я получаю нулевое исключение.
Мой код выглядит следующим образом:
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");
}
}