Error getting dialog! java.lang.RuntimeException: Sequence number should not decrease !

11 views
Skip to first unread message

Raziya Bhayani

unread,
Mar 17, 2009, 12:22:03 AM3/17/09
to mobicent...@googlegroups.com
Hi All,

What I am trying to do is, at a particular instance of System time, call up a set of people together and get them connected to a conference.

However, my this particular piece of code:

    public void onConnectionHalfOpen(MsConnectionEvent event,
            ActivityContextInterface aci) {
        try {
            MsConnection msConnection = event.getConnection();
            String sdp = msConnection.getLocalDescriptor();
            this.setPREndpointName(msConnection.getEndpoint().getLocalName());
           
           
            log.info(" connectionHalfOpen " + this.getPREndpointName() + " "+ this.toString());
           
            Request request = this.buildInvite(this.getCalleeAddress(), this
                    .getCallerAddress(), sdp.getBytes(), count.getAndIncrement(), null);
            ClientTransaction ct = sipProvider.getNewClientTransaction(request);
            this.setCallerClientTransaction(ct);
            Header h = ct.getRequest().getHeader(CallIdHeader.NAME);
            String calleeCallId = ((CallIdHeader) h).getCallId();
           
            Dialog dialog = ct.getDialog();

            if (dialog != null && log.isDebugEnabled()) {
                log
                        .debug("Obtained dialog from ClientTransaction : automatic dialog support on");
            }
            if (dialog == null) {
                // Automatic dialog support turned off
                try {
                    dialog = sipProvider.getNewDialog(ct);
                    if (log.isDebugEnabled()) {
                        log
                                .debug("Obtained dialog for INVITE request to callee with getNewDialog");
                    }
                } catch (Exception e) {
                    log.error("Error getting dialog", e);
                if (log.isDebugEnabled()) {
                log
                        .debug("Obtained dialog in onThirdPCCTriggerEvent : callId = "
                                + dialog.getCallId().getCallId());
            }
            // Get activity context from factory
            ActivityContextInterface sipACI = sipACIF
                    .getActivityContextInterface((DialogActivity) dialog);

   

            sipACI.attach(this.sbbContext.getSbbLocalObject());
            this.setDialogACI(sipACI);
            ct.sendRequest();
        }
Throws the above mentioned error,  it being: RuntimeException and it fails to get a Dialog. Here's a trace:

01:09:00,243 ERROR [DialoutSbb] Error getting dialog
java.lang.RuntimeException: Sequence number should not decrease !
    at gov.nist.javax.sip.stack.SIPDialog.setLocalSequenceNumber(SIPDialog.java:1268)
    at gov.nist.javax.sip.stack.SIPDialog.addTransaction(SIPDialog.java:1150)
    at gov.nist.javax.sip.stack.SIPDialog.<init>(SIPDialog.java:330)
    at gov.nist.javax.sip.stack.SIPTransactionStack.createDialog(SIPTransactionStack.java:550)
    at gov.nist.javax.sip.SipProviderImpl.getNewDialog(SipProviderImpl.java:837)
    at org.mobicents.slee.resource.sip11.SleeSipProviderImpl.getNewDialog(SleeSipProviderImpl.java:373)
    at org.mobicents.slee.resource.sip11.SleeSipProviderImpl.getNewDialog(SleeSipProviderImpl.java:364)
    at org.mobite.mucc.slee.callcontrol.dialout.DialoutSbb.onConnectionHalfOpen(DialoutSbb.java:174)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.mobicents.slee.runtime.sbbentity.SbbEntity.invokeEventHandler(SbbEntity.java:873)
    at org.mobicents.slee.runtime.EventRouterImpl.routeQueuedEvent(EventRouterImpl.java:933)
    at org.mobicents.slee.runtime.EventRouterImpl.access$100(EventRouterImpl.java:64)
    at org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:121)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)

And this is how buildInvite() looks....


    public Request buildInvite(Address toAddress, Address fromAddress,
            byte[] content, int cSeq, String callId)
            throws java.text.ParseException, InvalidArgumentException {
        Request request = null;
        try {

            // From Header:
            FromHeader fromHeader = headerFactory.createFromHeader(fromAddress,
                    generateTag());

            LocationSbbLocalObject handler = getLocationSbb();
            Map<String, RegistrationBinding> bindings = handler
                    .getBindings(toAddress.toString());
            String tempContactAddress = null;
            for (RegistrationBinding r : bindings.values()) {
                if (r.getSipAddress().equals(toAddress.toString())) {
                    tempContactAddress = r.getContactAddress();
                    log.info("did it =" + tempContactAddress);
                    break;
                }
            }
            Address contactAddress = addressFactory
                    .createAddress(tempContactAddress);
            // To header:
            ToHeader toHeader = headerFactory.createToHeader(toAddress, null);

            CSeqHeader cseqHeader = headerFactory.createCSeqHeader((long) cSeq,
                    Request.INVITE);

            // Create the Via header and add to an array list
            ArrayList viaHeadersList = new ArrayList();
            viaHeadersList.add(createLocalViaHeader());

            MaxForwardsHeader maxForwardsHeader = headerFactory
                    .createMaxForwardsHeader(70);

            final URI requestURI = convertAddressToSipURI(contactAddress);

            /*
             * Create the request
             */
            CallIdHeader callIdHeader = sipProvider.getNewCallId();

            if ((callId != null) && (callId.trim().length() > 0)) {
                callIdHeader.setCallId(callId);
            }


            request = messageFactory.createRequest(requestURI, Request.INVITE,
                    callIdHeader, cseqHeader, fromHeader, toHeader,
                    viaHeadersList, maxForwardsHeader);

            if (content != null) {
                setContent(request, "application", "sdp", content);
            }

            ContactHeader contactHeader = createLocalContactHeader();
            request.setHeader(contactHeader);

            if (log.isDebugEnabled()) {
                log.debug("Contact Header = " + contactHeader);
            }
        } catch (CreateException ce) {
            ce.printStackTrace();
        } catch (LocationServiceException e) {
            e.printStackTrace();
        }

        return request;
    }


Please can someone advise me as to what's the issue about and can I get it fixed?

Any help would be appreciated.

Thanks and regards,
Raziya




Raziya Bhayani

unread,
Mar 17, 2009, 2:53:52 AM3/17/09
to mobicent...@googlegroups.com
Thanks, got it resolved. However, would like to know if the approach adapted to generate a CSeq would be right? 

The issue was with generation of cseq num using 'count' as an AtomicInteger (count.getAndIncrement()). I was instantiating it with a '0' instead of '1'.

Regards,
Raziya

Raziya Bhayani

unread,
Mar 17, 2009, 3:12:39 AM3/17/09
to mobicent...@googlegroups.com
One more thing which I wanted to point out was, when I build an invite and send it, I get following NPE. The call gets established and proceeds well.

12:16:00,155 INFO  [SipResourceAdaptor] Received Response:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.0.102:5060;branch=z9hG4bK65bc1fdeaabb8942ca8313d2556b2e60
To: <sip:us...@mobite.co.in>
From: "sip:mobit...@mobite.co.in" <sip:mobit...@mobite.co.in>;tag=8755
Call-ID: 8cf7386fd146f700...@192.168.0.102
CSeq: 4 INVITE
Server: Twinkle/1.2
Content-Length: 0


12:16:00,177 INFO  [SipResourceAdaptor] Received Response:
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.0.102:5060;branch=z9hG4bK65bc1fdeaabb8942ca8313d2556b2e60
To: <sip:us...@mobite.co.in>;tag=fshpf
From: "sip:mobit...@mobite.co.in" <sip:mobit...@mobite.co.in>;tag=8755
Call-ID: 8cf7386fd146f700...@192.168.0.102
CSeq: 4 INVITE
Server: Twinkle/1.2
Content-Length: 0


12:16:00,177 ERROR [STDERR] java.lang.NullPointerException
12:16:00,177 ERROR [STDERR]     at org.mobicents.slee.resource.sip11.wrappers.DialogWrapper.fetchData(DialogWrapper.java:1519)
12:16:00,177 ERROR [STDERR]     at org.mobicents.slee.resource.sip11.wrappers.DialogWrapper.processIncomingResponse(DialogWrapper.java:1158)
12:16:00,178 ERROR [STDERR]     at org.mobicents.slee.resource.sip11.SipResourceAdaptor.processResponse(SipResourceAdaptor.java:994)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:290)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.SipProviderImpl.handleEvent(SipProviderImpl.java:158)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.DialogFilter.processResponse(DialogFilter.java:1035)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.stack.SIPClientTransaction.inviteClientTransaction(SIPClientTransaction.java:850)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.stack.SIPClientTransaction.processResponse(SIPClientTransaction.java:548)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.stack.SIPClientTransaction.processResponse(SIPClientTransaction.java:1479)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.stack.UDPMessageChannel.processMessage(UDPMessageChannel.java:505)
12:16:00,178 ERROR [STDERR]     at gov.nist.javax.sip.stack.UDPMessageChannel.processIncomingDataPacket(UDPMessageChannel.java:419)
12:16:00,179 ERROR [STDERR]     at gov.nist.javax.sip.stack.UDPMessageChannel.run(UDPMessageChannel.java:257)
12:16:00,179 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:595)
12:16:06,195 INFO  [SipResourceAdaptor] Received Response:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.102:5060;branch=z9hG4bK65bc1fdeaabb8942ca8313d2556b2e60
To: <sip:us...@mobite.co.in>;tag=fshpf
From: "sip:mobit...@mobite.co.in" <sip:mobit...@mobite.co.in>;tag=8755
Call-ID: 8cf7386fd146f700...@192.168.0.102
CSeq: 4 INVITE
Contact: <sip:us...@192.168.0.100:5076>
Content-Type: application/sdp
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,PRACK,REFER,NOTIFY,SUBSCRIBE,INFO,MESSAGE
Server: Twinkle/1.2
Supported: replaces,norefersub
Content-Length: 209

v=0
o=twinkle 2042525188 2105126068 IN IP4 192.168.0.100
s=-
c=IN IP4 192.168.0.100
t=0 0
m=audio 8000 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

Why this NPE is thrown from Sip11RA wrapper?

Keep advised.

Thanks.
Raziya

On Tue, Mar 17, 2009 at 9:52 AM, Raziya Bhayani <raziya...@gmail.com> wrote:

Eduardo Martins

unread,
Mar 17, 2009, 5:55:14 AM3/17/09
to mobicent...@googlegroups.com
Why do you need to store the cseq? This is more or less just a
formality of the JAIN SIP API so just use
headerFactory.createCSeqHeader(1L, Request.INVITE)

-- Eduardo

Eduardo Martins

unread,
Mar 17, 2009, 5:58:16 AM3/17/09
to mobicent...@googlegroups.com, Bartosz Baranowski
This seems a bug in the DialogWrapper, the response neither has
request uri, neither contact header, Bartosz can you handle this one
too? :)

-- Eduardo

Raziya Bhayani

unread,
Mar 17, 2009, 6:19:42 AM3/17/09
to mobicent...@googlegroups.com
Thanks Eduardo.
Reply all
Reply to author
Forward
0 new messages