How to continually reregister using Jain SIP?

I currently use Jain-Sip to successfully send a REGISTER request and get a 401 UnAuth back, I then use the nonce to generate the response and send it back and I successfully get a 200 OK response.
However when I go to re register again I cant seem to be able to send the request again, I keep getting null pointer exceptions.
Here is my code:
public class CSip extends Activity implements javax.sip.SipListener {
     private static AddressFactory addressFactory;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        digest = new DigestClientAuthenticationMethod();
        myAddress = getLocalIpAddress();
        tv = new TextView(this);  
        setContentView(tv);
             try {
                init(tv);
                register();
             } catch (Exception ex) {
                tv.append("Unxpected exception " + ex.getMessage());
                ex.printStackTrace();
    super.finish();
    public void init(TextView tv) throws Exception {
          SipFactory sipFactory = null;
          sipStack = null;
          sipFactory = SipFactory.getInstance();
          sipFactory.setPathName("gov.nist");
          Properties properties = new Properties();
          properties.setProperty("javax.sip.STACK_NAME", "Sip_Test");
          // Create SipStack object
          sipStack = sipFactory.createSipStack(properties);
          tv.setText("sipStack = " + sipStack);
          headerFactory = sipFactory.createHeaderFactory();
          addressFactory = sipFactory.createAddressFactory();
          messageFactory = sipFactory.createMessageFactory();
          lp = sipStack.createListeningPoint(getLocalIpAddress(),
                    8002, ListeningPoint.UDP);
          if(sipProvider == null){
          sipProvider = sipStack.createSipProvider(lp);
          sipOnOffFlag = true;
          tv.append("\n jain sip stack started on " + getLocalIpAddress() + ":" + myPort + "/" + ListeningPoint.UDP + " ");
          sipProvider.addSipListener(this);
          Log.d("INIT", "SipProvider = : " + sipProvider.toString());
    public void register()throws Exception{
          String fromName = "xxxxxxxx";
          String fromSipAddress = "sip.network.com";
          String toSipAddress = "sip.network.com";
          String toUser = "xxxxxxxx";
          SipURI fromAddress = addressFactory.createSipURI(fromName,
                    fromSipAddress);
          Address fromNameAddress = addressFactory.createAddress(fromAddress);
          FromHeader fromHeader = headerFactory.createFromHeader(
                    fromNameAddress, null);
          SipURI toAddress = addressFactory
                    .createSipURI(toUser, toSipAddress);
          Address toNameAddress = addressFactory.createAddress(toAddress);
          ToHeader toHeader = headerFactory.createToHeader(toNameAddress,
                    null);
          URI requestURI = addressFactory.createURI(
                    "sip:" + "sip.network.com");
          List<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
          String ipAddress = lp.getIPAddress();
          ViaHeader viaHeader = headerFactory.createViaHeader(ipAddress,
                    lp.getPort(),
                    lp.getTransport(), null);
          viaHeaders.add(viaHeader);
          CallIdHeader callIdHeader = sipProvider.getNewCallId();
          CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1L,
                    Request.REGISTER);
          MaxForwardsHeader maxForwards = headerFactory
                    .createMaxForwardsHeader(70);
          Request request = messageFactory.createRequest(requestURI,
                    Request.REGISTER, callIdHeader, cSeqHeader, fromHeader,
                    toHeader, viaHeaders, maxForwards);
          SipURI contactUrl = addressFactory.createSipURI(fromName, fromSipAddress);
          contactUrl.setPort(8002);
          contactUrl.setLrParam();
          SipURI contactURI = addressFactory.createSipURI(fromName, "sip.network.com");
          contactURI.setPort(sipProvider.getListeningPoint(lp.getTransport())
                    .getPort());
          Address contactAddress = addressFactory.createAddress(contactURI);
          contactHeader = headerFactory.createContactHeader(contactAddress);
          request.addHeader(contactHeader);
          Header extensionHeader = headerFactory.createHeader("Expires",
               "120");
          request.addHeader(extensionHeader);
          Log.d("SIP", "" + request.toString());
          // Create the client transaction.
          Log.d("BEFORE TID", "SipProvider = : " + sipProvider.toString());
          inviteTid = sipProvider.getNewClientTransaction(request);
          inviteTid.sendRequest();
          Log.d("AFTERSENDREQUEST", "SipProvider = : " + sipProvider.toString());
          Log.d("INVITETID", "inviteTid = " + inviteTid.getState());
          dialog = inviteTid.getDialog();
     public void processResponse(ResponseEvent responseEvent) {
          Log.d("RESPONSE", "response " + responseEvent.getResponse());
          Message message = Message.obtain();
          message.obj = "received response "+responseEvent.getResponse();
          handler.sendMessage(message);     
          Response response = (Response) responseEvent.getResponse();
          ClientTransaction tid = responseEvent.getClientTransaction();
          CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);                    
          Log.d("STATUS CODE", "status code = " + response.getStatusCode());
          Log.d("STATUS CODE", "header code = " + response.getHeader("WWW-Authenticate"));
          Log.d("STATUS CODE", "reason code = " + response.getReasonPhrase());
          CallIdHeader callid = (CallIdHeader) response.getHeader("Call-ID");
          WWWAuthenticate wwwAuth = (WWWAuthenticate) response.getHeader("WWW-Authenticate");
          Log.d("STATUS NONCE", ", nonce : " + wwwAuth.getNonce());
          Log.d("STATUS NONCE", "nonce : " + wwwAuth.getNonce());
          String nonce = wwwAuth.getNonce();
          String cNonce = wwwAuth.getCNonce();
          Log.d("STATUS ", "cnonce : " + cNonce);
          String realm = wwwAuth.getRealm();
          Log.d("STATUS ", "realm : " + realm);
          String method = wwwAuth.getQop();
          Log.d("STATUS", "method : " + method);
          String alg = wwwAuth.getAlgorithm();
          Log.d("STATUS", "alg : " + alg);
          String authResponse = null;
          AuthorizationHeader authHeader = null;
          try {
               digest.initialize(realm,"xxxxxxxx","sip:sip.network.com",
                         nonce,"xxxxxxx", "REGISTER",null, alg);
               Log.d("GENRESPONSE", "" + digest.generateResponse());
               authResponse = digest.generateResponse();
          } catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          try {
                authHeader = headerFactory.createAuthorizationHeader("Digest");
                authHeader.setUsername("xxxxxxxx");
                authHeader.setRealm(realm);
                authHeader.setNonce(nonce);
                authHeader.setResponse(authResponse);
                authHeader.setAlgorithm(alg);
                URI authURI = addressFactory.createURI(
                              "sip:" + "sipnetworks.com");
                authHeader.setURI(authURI);
          } catch (ParseException e) {
               e.printStackTrace();
          Log.d("AUTH HEADER", "Auth Header = " + authHeader);
          if (response.getStatusCode() == Response.UNAUTHORIZED){
          try {
               authHeader.setNonceCount(1);
               createAuthReply(authHeader, callid);
          } catch (Exception e) {
               e.printStackTrace();
          scheduleReRegistration(120, callid);     
     }

I have tried putting in my register() method several times and if I call the different register() methods,
so call register() then register2() then register3() it works this way.
But not if I simply put register() in a timer looping.
So there must be something I have to terminate and restart or something each time I run the method?
Edited by: draffodx on Feb 11, 2010 10:12 AM

Similar Messages

  • Jain SIP sample code to do a VOIP...

    Hi,
    Right now I have a problem with my current project, can somebody give me some sample codes/can help me on how to make an client VOIP application using Jain SIP API to do a VOIP call... I have an PBX Server but i dont know how to start writing my application to connect to my server...
    thanks,
    dOnie

    [https://jain-sip.dev.java.net/]
    Edited by: cotton.m on 10-Jun-2010 10:05 AM

  • Current JAIN-SIP RI (JSR 32)

    Hello to the community of JAIN-SIP (JSR 32),
    I'm a student currently working on a project utilizing
    JAIN-SIP 1.2 RI in the implementation of the application.
    In the application, there is an API from another project
    being used that has a SipListener implementation. I would
    like to develop my application using existing RI's or any
    interface implementations as much as possible to avoid the
    need of implementing interfaces required to run my
    application.
    The API mentioned earlier involves pure TCP transfer of data
    only, and it serves as the network setup layer of my
    applicaiton that establishes SIP conferencing. An exception
    of "listening point not found for this provider" was observed
    which failed the setup of the conference. It was discovered
    later that the DefaultRouter class in gov.nist.javax.sip.stack
    package defaults the transfer type to UDP which causes the
    error. After this has been changed to TCP, things worked fine.
    I'm trying to avoid packaging this "fix" into my application as
    I would like people using the application to obtain their copy
    of the JAIN-SIP RI. Fiddling with a public RI probably isn't a
    good idea!
    Is it possible to change the default transfer type in the default
    router to TCP instead of UDP? Can this change be realized
    by the JAIN-SIP community in the form of a new release of the RI?
    Or...any suggestions for possible solutions the this problem?
    Thanks for looking into this,
    Any comment is greatly appreciated!

    Hi,
    I got error 500 Internal Server Error when i send a text message from jain-sip client, Client send the Text message to server but server return the above error.
    There is no Text Message Handler Code in Server Proxy Class,
    Also when i try to start Voice Connversation, Client sent a INVITE request to server but server return 500 Server Intnal Error. also there is no INVITE handler code in Server Proxy Class.
    I am using jain-sip-presence-proxy SIP server and jain-sip-applet-phone.
    please help me .......................................Its Urgent
    why server could not handle the text or voice messages.
    How i make the text and voice conversation.
    with regards

  • Memory leak in Jain-SIP ?

    Hi there.
    We implemented a SIP gateway to MS OCS 2007 using
    Jain-SIP version 1.2.1906.
    One problem we have is memory consumption.
    Using jconsole we found out that memory is not
    completely released when SIP clients log out.
    E.g. the following classes keep on accumulating:
    53134 instances of class gov.nist.core.NameValueList
    41730 instances of class gov.nist.core.NameValue
    20330 instances of class gov.nist.core.Host
    20330 instances of class gov.nist.core.HostPort
    19767 instances of class gov.nist.core.DuplicateNameValueList
    19767 instances of class gov.nist.core.MultiValueMapImpl
    16162 instances of class gov.nist.javax.sip.address.Authority
    16162 instances of class gov.nist.javax.sip.address.SipUri
    13570 instances of class gov.nist.javax.sip.address.UserInfo
    12261 instances of class gov.nist.javax.sip.address.AddressImpl
    5210 instances of class gov.nist.javax.sip.header.Protocol
    5210 instances of class gov.nist.javax.sip.header.Via
    4168 instances of class gov.nist.javax.sip.header.CallID
    4168 instances of class gov.nist.javax.sip.header.CallIdentifier
    3901 instances of class gov.nist.javax.sip.header.CSeq
    3901 instances of class gov.nist.javax.sip.header.ContentLength
    3901 instances of class gov.nist.javax.sip.header.From
    3901 instances of class gov.nist.javax.sip.header.MaxForwards
    3901 instances of class gov.nist.javax.sip.header.RequestLine
    3901 instances of class gov.nist.javax.sip.header.To
    3901 instances of class gov.nist.javax.sip.header.ViaList
    3901 instances of class gov.nist.javax.sip.message.SIPRequest
    3901 instances of class gov.nist.javax.sip.stack.SIPTransaction$TransactionSemaphore
    2858 instances of class gov.nist.javax.sip.DialogFilter
    2618 instances of class gov.nist.javax.sip.header.Route
    2618 instances of class gov.nist.javax.sip.header.RouteList
    2592 instances of class gov.nist.javax.sip.stack.SIPServerTransaction
    2590 instances of class gov.nist.javax.sip.header.ContentDisposition
    2590 instances of class gov.nist.javax.sip.header.ContentType
    2590 instances of class gov.nist.javax.sip.header.MediaRange
    1579 instances of class org.apache.xmlbeans.SchemaType$Ref
    1309 instances of class gov.nist.javax.sip.header.UserAgent
    1309 instances of class gov.nist.javax.sip.parser.Pipeline
    1309 instances of class gov.nist.javax.sip.parser.PipelinedMsgParser
    1309 instances of class gov.nist.javax.sip.parser.StringMsgParser
    1309 instances of class gov.nist.javax.sip.stack.HopImpl
    1309 instances of class gov.nist.javax.sip.stack.SIPClientTransaction
    1309 instances of class gov.nist.javax.sip.stack.SIPClientTransaction$TransactionTimer
    1309 instances of class gov.nist.javax.sip.stack.SIPDialog
    These all are classes from the SIP stack aren't they ?
    Are there any known issues with memory leaks
    in Jain-SIP ?
    Is it probably a configuration issue with
    the properties/parameters for the SIP stack ?
    (There is a property gov.nist.javax.sip.AGGRESSIVE_CLEANUP which we set
    to TRUE but it didn't help)
    Do we miss to release/initialize anything in the SIP stack manually ?
    Thanks a lot in advance,
    Fred

    Nobody else seems ton have this problem. I haven't run my SIP code for as long as a week at a time but i didn't notice any undue memory usage, and I also trawled inside the source a lot without seeing anything odd. So is it your code leaking? Are you sure you're releasing everything to do with a conversation when it ends? Rather than say accumulating things in some static data structure?

  • How does one continue to use Mail on the early MacBook Pro, Model 1,1, that is not upgradable to Lion?  I have been running iCloud on my iPhone (OS5) and iMac (Lion) along with the MacBook Pro (OS Version 10.6.8)

    How does one continue to use Mail on the early MacBook Pro, Model 1,1, that is not upgradable to Lion?  I have been running iCloud on my iPhone (OS5) and iMac (Lion) along with the MacBook Pro (OS Version 10.6.8) since November until now.  Mail will no longer download on the MacBook Pro and keeps asking for my password.

    Mail should still be usable with your machine - but you'll need to update the settings to conform to the requirements of your system. Check with your ISP (like ATT, etc.) for the settings that will work with your Mail. Once you've updated this, you should be able to email like before.
    For example, my ISP required that I go to Mail Preferences/Accounts and make sure the details conform to your email settings.
    I have no idea of what your ISP is or what the settings might be, but this is likely the source of the problem.

  • I recently bought an iphone 4s from people who are not in the know and restore my iphone .. Now do not be in use for not having ID and password ... Owner apple owner just gave me a serial number how do I want to continue to use this ... Their telephone he

    I recently bought an iphone 4s from people who are not in the know
    and restore my iphone .. Now do not be in use for not having ID and password ... Owner apple owner just gave me a serial number how do I want to continue to use this ... Their telephone help me: (

    I am having same problem . i can not use the phone. my Carrier ROGERS checked the phone its not stolen or lost phone but after restoring always ask for apple ID of previous owner and seller is not responding to any mails or phone if some one can help me out than it will be great.
    thank you

  • I have an Epson scanner that is apparently no longer supported  because it is a PowerPC app.  It's a very good scanner that worked fine until I upgraded to OS Mountain Lion on my MacBook Pro.  Any suggestions on how I can continue to use it?

    I have an Epson scanner that is apparently no longer supported  because it is a PowerPC app.  It's a very good scanner that worked fine until I upgraded to OS Mountain Lion on my MacBook Pro.  Any suggestions on how I can continue to use it?

    For that model, Epson has this information:
    ICA Scanner Driver
    07/17/12
    Description: The latest Mac OS X ICA scanner driver for your Epson product is available only via Apple's Software Update. Here's how to get it:
    1. Connect the all-in-one or scanner to your Mac and power it on.
    2. Select the  menu, then Software Update.
    3. Follow the on-screen instructions to install the available updates.
    Note: Software Updates may find multiple updates for your system. You may choose to install all or some of the updates by clicking on Show Details.
    Compatible Systems: Mac OS X (v10.8.x)

  • How do I remove my phone number from my iphone so that i can continue to use it like an ipod touch and use imessages with email/apple ID?

    How do i remove my phone number from my iphone 4s so that i can continue to use it as an ipod touch and use imessages with email/apple ID?

    This article explains what to do:
    http://support.apple.com/kb/HT5661

  • HT4929 I have a power mac using Tiger so how do I to continue to use mail on my computer?

    Hello,
    I have a power mac using Tiger so how do I to continue to use mail on my computer?
    Please Help. I love using Mail on my G4.
    Thank you.
    Gaynor Kemmett.

    Thank you so much for your outstanding information. Even me - a 52 year old die hard Power Mac G4 Tiger user was able to follow the simple directions and I know have a iCloud account. Yeah!!! Thank you.
    Gaynor.

  • How can I continue to use my library of appleworks 6 drawings and sketches with Mountain Lion.

    How can I continue to use my library of appleworks 6 drawings and sketches with Mountain Lion?  Wednesday Jan. 30.  by Turtlelady.

    Now with iTunes 10.4 no iphone appears on the left sidebar
    Try removing and reinstalling the AMDS...
    iTunes: How to remove and reinstall the Apple Mobile Device Service on Mac OS X

  • I cannot use iPhoto now there is Photo on my mac. How can I continue to use iPhoto

    I cannot use iPhoto now there is Photo on my mac. How can I continue to use iPhoto

    You can, why do you think it's not possible? Does  need updating?
    Go to the App Store and check out the Purchases List. If iPhoto is there then it will be v9.6.1
    If it is there, then drag your existing iPhoto app (not the library, just the app) to the trash
    Install the App from the App Store.
    Sometimes iPhoto is not visible on the Purchases List. it may be hidden. See this article for details on how to unhide it.
    http://support.apple.com/kb/HT4928
    One question often asked: Will I lose my Photos if I reinstall?
    iPhoto the application and the iPhoto Library are two different parts of the iPhoto programme. So, reinstalling the app should not affect the Library. BUT you should always have a back up before doing this kind of work. Always.

  • How do I continue to use Mail on my MacBook2? i use iCloud on my iPhone and iPad but cannot receive my Mail account on my older MacBook.

    how do I continue to use Mail on my MacBook2? i use iCloud on my iPhone and iPad but cannot receive my Mail account on my older MacBook. I have followed the iCloud/move link as suggested but it doesn't give me the continue to use Mail option. Any help gratefully received.

    Welcome to the Apple Community.
    Delete your mail account from Mail preferences and set it up again using the Mail Server Information.
    Some users have apparently encountered issues using this information in pre-Lion set ups (I haven't), Roger Wilmut has kindly provided instructions for those who find themselves with this problem.
    Entering iCloud email settings manually in Snow Leopard or Leopard

  • How to receive 100 Continue responses using HttpURLConnection

    Hi there,
    My server returns:
    HTTP/1.1 100 Continue
    Set-Cookie: Cookie1=Value1
    Server: Microsoft-IIS/5.0
    Date: Mon, 29 Sep 2000 18:34:02 GMT
    HTTP/1.0 200 OK
    Server: Server 2
    Set-Cookie: Cookie2=Value2
    Content-Type: text/html
    I'm using HttpURLConnection to get the response.
    I need to get both responses, however HttpURLConnection only returns the 200 OK response.
    How do I get the 100 Continue response using this class? I need it to retrieve the cookie.
    Thanks.

    You can't. If you check the j2se source code you will notice that sun.net.www.http.HttpClient just drops the '100 Continue' and waits for the actual response that follows.

  • How would I import multiple Roadrunner emails each with multiple folders and continue to use my Roadrunner email to send and receive?

    How would I import multiple Roadrunner emails each with multiple folders into Apple Mail and continue to use my Roadrunner email to send and receive from within Mail?

    Try this.. Click the first in the CC field hold Shift, Click the Second Third, Fouth, Fifth and so on... click right Mouse select add to Contacts.

  • Changed my ID but the Iphone 4 continue with the old ID name and does not syncronize. How can I change it in my Iphone so I can continue to use all my data stored like contacts and notes?

    Changed my ID but the Iphone 4 continue with the old ID name and does not syncronize. How can I change it in my Iphone so I can continue to use all my data stored like contacts and notes?

    Do you mean through iCloud?  You need to go to settings > iCloud and "delete account" and then sign in with the newly named account.  You'll want to do similar for facetime, messages, and store.

Maybe you are looking for

  • Some Questions I Have About the GE70 Apache Pro

    Hi Y'all,     I'm new here to the MSI Community and am looking to make my first purchase of a MSI Notebook.   I'm looking at the new GE 70 Apache Pro because of the budget I have to work with thanks to having to go out and spend $6K to get my car fix

  • How do I manage a different ipod to the songs which are in my iTunes?

    Hi there, just received an old iPod froma friend of mine... and when I plug it into iTunes, I can see all his songs and playlists but cannot access any of them meaning it does not allow me to click on them to play delete or alter the playlists... I w

  • Paste is only pasting a text field instead of an image copied to the clipboard from another program like mail or safari?

    The latest version of Keynote only pastes a blank text field after copying an image to the clipboard in other applications like mail or Safari.  The previous version worked fine with copying and pasting images.  Saving the image to a file and then in

  • Only show selected movies on AppleTV 2

    Some of the movies in my iTunes library I would prefer to hide from or make otherwise not accessible for my kids when they use the ATV2. On the ATV1 i was able to simply uncheck the movie in iTunes and then re-sync. In ATV2 the movie remains visible

  • Multiple galleries with accordion

    Hi! I've been using Spry for a school project; I've developed a gallery as an example. You can see it here: http://lavalamp.altervista.org/gallery/ I would say that it's finished, but I still have a couple of issues I want to resolve (or understand,