forward call in b2bua jain slee

53 views
Skip to first unread message

ichi

unread,
Jul 21, 2011, 4:32:44 AM7/21/11
to mobicents-public
Hi everyone, I'd like to modify a bit the b2bua example to forward all
incoming call to an address. I found this error:

10:04:28,602 ERROR [DisponibilitySbbImpl] Failed to process incoming
INVITE.
java.lang.NullPointerException
at
gov.nist.javax.sip.SipProviderImpl.getNewClientTransaction(SipProvide
rImpl.java:401)
at
org.mobicents.slee.resource.sip11.SleeSipProviderImpl.getNewClientTra
nsaction(SleeSipProviderImpl.java:431)
at
org.mobicents.slee.disponible.DisponibilitySbb.onINVITE(Disponibility
Sbb.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.mobicents.slee.runtime.sbbentity.SbbEntityImpl.invokeEventHandler
(SbbEntityImpl.java:497)
at
org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskIm
pl.routeQueuedEvent(EventRoutingTaskImpl.java:378)
at
org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskIm
pl.run(EventRoutingTaskImpl.java:126)
at
org.mobicents.slee.runtime.eventrouter.EventRouterExecutorImpl$EventR
outingTaskStatsCollector.run(EventRouterExecutorImpl.java:73)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:662)

which pointed out in the following line:

ClientTransaction ct =
sipProvider.getNewClientTransaction(invite);

Any hint where's the cause of Null in the outgoing request? I only
tried to change the ToHeader. Here's the code.

public void onINVITE(javax.sip.RequestEvent event,
ActivityContextInterface aci) {

request = event.getRequest();
tracer.info("Receiving INVITE");
aci.detach(sbbContext.getSbbLocalObject());

try {
final DialogActivity incomingDialog = (DialogActivity) sipProvider
.getNewDialog(event.getServerTransaction());
final ActivityContextInterface incomingDialogACI = sipAciFac
.getActivityContextInterface(incomingDialog);

//Create a request
String toSipAddress = "open-ims.test";
String toUser = "bob";
String toDisplayName = "Bob";
SipURI toAddress = addressFac.createSipURI(toUser, toSipAddress);
javax.sip.address.Address toNameAddress =
addressFac.createAddress(toAddress);
ToHeader toHeader = headerFac.createToHeader(toNameAddress, null);
FromHeader fromHeader = (FromHeader)
request.getHeader(FromHeader.NAME);
MaxForwardsHeader maxForwards = (MaxForwardsHeader)
request.getHeader(MaxForwardsHeader.NAME);
ContentTypeHeader originalContent = (ContentTypeHeader)
request.getHeader(ContentTypeHeader.NAME);
ContentTypeHeader contentTypeHeader =
headerFac.createContentTypeHeader(originalContent.getContentType(),
originalContent.getContentSubType());
ListIterator<ViaHeader> iter = request.getHeaders(ViaHeader.NAME);

ArrayList viaHeaders = new ArrayList();
while(iter.hasNext()){
ViaHeader viaHeader = iter.next();
ViaHeader viaHeaderr =
headerFac.createViaHeader(viaHeader.getHost(), viaHeader.getPort(),
viaHeader.getProtocol(), "null");
viaHeaders.add(viaHeaderr);
}

CallIdHeader callId = sipProvider.getNewCallId();
SipURI requestURI = (SipURI) request.getRequestURI();
ContactHeader contact =
(ContactHeader)request.getHeader(ContactHeader.NAME);
long cseq = 1;
CSeqHeader cSeq = headerFac.createCSeqHeader(cseq, request.INVITE);
String sdp = null;
if(event.getRequest().getContent()!=null){
sdp = new String(event.getRequest().getRawContent());
}

//Send the Request INVITE
Request invite =
messageFac.createRequest(contact.getAddress().getURI(),
request.INVITE, callId, cSeq, fromHeader, toHeader, viaHeaders,
maxForwards, contentTypeHeader, sdp);
invite.addHeader(contact);
ClientTransaction ct = sipProvider.getNewClientTransaction(invite);
final DialogActivity outgoingDialog = (DialogActivity)
sipProvider.getNewDialog(ct);

//Attach outgoing dialog
final ActivityContextInterface outgoingDialogACI = sipAciFac
.getActivityContextInterface(outgoingDialog);

final SbbLocalObject sbbLocalObject = sbbContext
.getSbbLocalObject();
incomingDialogACI.attach(sbbLocalObject);
outgoingDialogACI.attach(sbbLocalObject);

setIncomingDialog(incomingDialogACI);
setOutgoingDialog(outgoingDialogACI);

tracer.info("Sending Second Leg");
outgoingDialog.sendRequest(ct);

} catch (Throwable e) {
tracer.severe("Failed to process incoming INVITE.", e);
replyToRequestEvent(event, Response.SERVICE_UNAVAILABLE);
}
}

Eduardo Martins

unread,
Jul 21, 2011, 6:46:54 AM7/21/11
to mobicent...@googlegroups.com
What version?

-- Eduardo
..............................................
http://emmartins.blogspot.com
http://redhat.com/solutions/telco

ichi

unread,
Jul 21, 2011, 9:30:23 AM7/21/11
to mobicents-public
I deployed in version 2.4.0.FINAL.

On Jul 21, 12:46 pm, Eduardo Martins <emmart...@gmail.com> wrote:
> What version?
>
> -- Eduardo
> ..............................................http://emmartins.blogspot.comhttp://redhat.com/solutions/telco

Eduardo Martins

unread,
Jul 21, 2011, 11:48:25 AM7/21/11
to mobicent...@googlegroups.com
The NPE occurs inside JAIN SIP RI, which should mean an issue with the
request content, probably related to using headers from one request in
another, try to .clone() each header you want to copy instead.

Anyway, the code does not seems to be best solution, when using
dialogs you should first create the dialog, using
sipProvider.getNewDialog(from,to) or
sipProvider.getNewDialog(incomingDialog,boolean), then copy request
using DialogActivity.createRequest(incomingRequest), extend it if
needed, and finally use the dialog to send the request
DialogActivity.sendRequest(outgoingRequest);

-- Eduardo
..............................................
http://emmartins.blogspot.com

http://redhat.com/solutions/telco

Reply all
Reply to author
Forward
0 new messages