×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    42

    Application crashes after automatic IAP selection & POST

    Hi,
    I need to periodically post data via HTTP POST method. I've tried to set automatically the IAP selection, but
    after the first POST method call, which succesfully transfer the data, application crashes on the device. In the emulator it works fine. I wondering where's the fault, can anybody help me, please?

    The automatic selection of IAP I'm doing in method AutoSetupConnectionL(), which is called in ConstructL of HTTPClient. Objects iSocketServ, iConnection, iSession and iTransaction are HTTP client class members.

    Code:
    void CClientEngine::AutoSetupConnectionL()
    {
        //TInt bearerFilter = EApBearerTypeAllBearers;
        TInt currentProfileId;
        
        // Check whether we are offline or online
        iRepository->Get(KProEngActiveProfile, currentProfileId);
    
        // Close the connection only if
        // a) this is not the first time and
        // b) the profile has changed and
        // c) either the previous or the current profile is Offline (5 = Offline)
        if (iPrevProfileId != -1 && iPrevProfileId != currentProfileId &&
           (iPrevProfileId == 5 || currentProfileId == 5))
            {
            // Close and uninitialize
            iConnectionSetupDone = EFalse;
            iSession.Close();
            iConnection.Close();
            iSocketServ.Close();
            }
        
        // Save current profile id
        iPrevProfileId = currentProfileId;
    
        // Try to find an existing connection. If connection has not been set up,
        // iConnection is not initialized and FindExistingConnection() fails.
        // Thus, in that case, finding must not be carried out.
        if (iConnectionSetupDone && !FindExistingConnection())
            {
            iConnectionSetupDone = EFalse;
            }
        
        if (iConnectionSetupDone)
            {
            // Connection setup is done
            return;
            }
        
        // Open RHTTPSession with default protocol ("HTTP/TCP")
        iSession.OpenL();
    
        User::LeaveIfError(iSocketServ.Connect());
        User::LeaveIfError(iConnection.Open(iSocketServ));
        
        TCommDbConnPref pref;
        iSelectedIap = 0;
        pref.SetIapId(iSelectedIap);
        pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
        pref.SetDirection(ECommDbConnectionDirectionOutgoing);
        pref.SetBearerSet( ECommDbBearerGPRS | ECommDbBearerCdma2000 | ECommDbBearerLAN | ECommDbBearerCSD );
    
        iConnection.Start(pref);
    
        RStringPool strP = iSession.StringPool();
        RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
        connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) );
        TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
        connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (connPtr) );
        
        iConnectionSetupDone = ETrue;
    }
    Then here's the POST method:

    Code:
    void CClientEngine::HttpPostL(const TDesC8& aUri, TDesC& aFileName)
      {
    	 // Parse string to URI
    	  TUriParser8 uri;
    	  uri.Parse(aUri);
    
    	  // Copy data to be posted into member variable; iPostData is used later in
    	  // methods inherited from MHTTPDataSupplier.
    	  delete iPostData;
    	  iPostData = 0;
    	  //iPostData = aBody.AllocL();
    
    	  // Get request method string for HTTP POST
    	  RStringF method = iSession.StringPool().StringF(HTTP::EPOST, RHTTPSession::GetTable());
    
    	  // Open transaction with previous method and parsed uri. This class will
    	  // receive transaction events in MHFRunL and MHFRunError.
    	  iTransaction = iSession.OpenTransactionL(uri, *this, method);
    
    	  // Set headers for request; user agent, accepted content type and body's
    	  // content type.
    	  LoadFileL(aFileName);  
    	  MakePostPacketL(aFileName);
    	  
    	  RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    	  SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    	  SetHeaderL(hdr, HTTP::EAccept, KAccept);
    	  SetHeaderL(hdr, HTTP::EContentType, KPostContentType);
    
    	  // Set this class as an data supplier. Inherited MHTTPDataSupplier methods
    	  // are called when framework needs to send body data.
    	  MHTTPDataSupplier* dataSupplier = this;
    	  iTransaction.Request().SetBody(*dataSupplier);
    
    	  // Submit the transaction. After this the framework will give transaction
    	  // events via MHFRunL and MHFRunError.
    	  iTransaction.SubmitL();
    	  
    	  iRunning = ETrue;
    	  //HBufC* resConnecting = StringLoader::LoadLC(R_HTTP_CONNECTING);
    	  //iObserver.ClientEvent(*resConnecting);
    	  //CleanupStack::PopAndDestroy(resConnecting);
    	  
    	  #if (DEBUG_APP == 1)	
    		TPtrC logPtr(_L("Happened iTransaction.SubmitL(); iRunning = ETrue; "));
    		Essential::LogL(logPtr);
    	  #endif  	  	 
      }
    Thank you, Petr.

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: Application crashes after automatic IAP selection & POST

    "Crashing"(Panic) would result some code. See this: Extended Panic Code
    Nokia Developer Wiki Moderation team

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    42

    Re: Application crashes after automatic IAP selection & POST

    Thanks for the link. I've installed Y-Tasks Crash Monitor and the result after crashing is "Main USER 130". I've found about it:
    "This panic is raised when an index value passed to a member function of a RArray or a RPointerArray identifying an array element, is out of bounds.", but I don't know about instances of these classes in my code, only if they would be base classes of some other objects in the HTTP Client class.

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Application crashes after automatic IAP selection & POST

    Quote Originally Posted by petr_kovar View Post
    Thanks for the link. I've installed Y-Tasks Crash Monitor and the result after crashing is "Main USER 130". I've found about it:
    "This panic is raised when an index value passed to a member function of a RArray or a RPointerArray identifying an array element, is out of bounds.", but I don't know about instances of these classes in my code, only if they would be base classes of some other objects in the HTTP Client class.
    If you do not know where u use RArray or a RPointerArray than who know it??? Search your projects with these words and check where u going wrong. Also put some logs to find location of panic.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    42

    Re: Application crashes after automatic IAP selection & POST

    I'm sorry, you're right. I'm using a little bit changed HTTP Client Example, so I meant that what I've said, it's possible there are some objects I am not aware. I tried to debug it in the emulator and I've fixed some things, but after calling CActiveScheduler::Start() in Main occurs a "Main Panic ALLOC: 201a32c4". Function launching the application, in which the panic occurs, is below. ClientCom class owns instance of HttpClient as a member, CSmsControl is an active object and has a reference to ClientCom class, so it can use the HTTP methods.

    Code:
    static void RunTheServerL()
    	{
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    		
    	//creating instance of communication class
    	CClientComm *ClientCom = CClientComm::NewLC();
    	
    	//creating instance of SMS control class
    	CSmsControl::NewLC(*ClientCom);
    		
    /////////////////
    	//after calling following line PANIC occurs
    	CActiveScheduler::Start();
    /////////////////
    	
    	//odstraneni serveru a planovace	
    	CleanupStack::PopAndDestroy(3, scheduler);
    	}
    I have these lines as last in debug trace:
    107.655 HTTPPLUGIN:MHFRunL: ESubmit (0)
    108.725 HTTPPLUGIN:MHFRunL: EGotResponseHeaders (4)
    108.735 HTTPPLUGIN:MHFRunL: EClosed (3)
    108.740 HTTPPLUGIN:[1fdd414c] destroyed
    108.750 Thread SilentSMSv4.exe::Main Panic ALLOC: 1fdd32e0
    so the error is in MHFRunL ?
    Last edited by petr_kovar; 2009-04-23 at 14:41.

  6. #6
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Application crashes after automatic IAP selection & POST

    Code:
    static void RunTheServerL()
    	{
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    		
    	//creating instance of communication class
    	CClientComm *ClientCom = CClientComm::NewLC();
    	
    	//creating instance of SMS control class
    	CSmsControl::NewLC(*ClientCom);
    		
    /////////////////
    	//after calling following line PANIC occurs
    	CActiveScheduler::Start();
    /////////////////
    	
    	//odstraneni serveru a planovace	
    	CleanupStack::PopAndDestroy(3, scheduler);
    	}
    Quote Originally Posted by S60 SDK
    At least one active object, with an outstanding request, must be added to the scheduler before the wait loop is started, otherwise no events will occur and the thread will hang, or any events that do occur will be counted as stray signals, raising a panic.

    Also Memory leak cause "ALOC: 0xxxxx" panic. You might forgot to delete some allocated memory. use hooklogger to find memory leak.
    http://wiki.forum.nokia.com/index.ph...ith_HookLogger

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    42

    Re: Application crashes after automatic IAP selection & POST

    Thank you, it's very useful tool ! I've used the HookLogger and found out there would be 2 memory leaks in method HTTPPost() as the last user generated on the top:

    Code:
    CClientEngine::HttpPostL(class TDesC8 const &,class TDesC16 &) 
    
    <C:\Symbian\Carbide\workspace\SilentSMSv4\src\HttpClient.cpp #511> + 32 - SilentSMSv4.exe! 
    
    24633a79()
    CFileSender::FileSendL(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\FileSender.cpp 
    
    #65> + 27 - SilentSMSv4.exe! 24632bb6()
    CClientComm::ConstructL(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\ClientComm.cpp 
    
    #52> + 7 - SilentSMSv4.exe! 24632134()
    CClientComm::NewLC(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\ClientComm.cpp #15> + 
    
    7 - SilentSMSv4.exe! 24631fab()
     <C:\Symbian\Carbide\workspace\SilentSMSv4\src\Main.cpp #37> + 5 - SilentSMSv4.exe! 
    
    24631064()
    E32Main(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\Main.cpp #83> + 63 - 
    
    SilentSMSv4.exe! 2463134a()
    __E32Startup <M:\src\cedar\generic\BASE\E32\EUSER\epoc\win32\uc_exe.cpp #46> + 12 - 
    
    SilentSMSv4.exe! 246355e2()
    Ordinal274 + 2410 - ekern.exe! 49fa9fd()
    Ordinal454 + 549 - ekern.exe! 49f8da2()
    kernel32.dll! 7c80b729()
    *********************************** 2nd leak  *************************
    >>>>http.dll! 7bd11c7()
    Ordinal124 + 326 - http.dll! 7bd1d58()
    Ordinal124 + 75 - http.dll! 7bd1c5d()
    CClientEngine::HttpPostL(class TDesC8 const &,class TDesC16 &) 
    
    <C:\Symbian\Carbide\workspace\SilentSMSv4\src\HttpClient.cpp #511> + 32 - SilentSMSv4.exe! 
    
    24633a79()
    CFileSender::FileSendL(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\FileSender.cpp 
    
    #65> + 27 - SilentSMSv4.exe! 24632bb6()
    CClientComm::ConstructL(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\ClientComm.cpp 
    
    #52> + 7 - SilentSMSv4.exe! 24632134()
    CClientComm::NewLC(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\ClientComm.cpp #15> + 
    
    7 - SilentSMSv4.exe! 24631fab()
     <C:\Symbian\Carbide\workspace\SilentSMSv4\src\Main.cpp #37> + 5 - SilentSMSv4.exe! 
    
    24631064()
    E32Main(void) <C:\Symbian\Carbide\workspace\SilentSMSv4\src\Main.cpp #83> + 63 - 
    
    SilentSMSv4.exe! 2463134a()
    __E32Startup <M:\src\cedar\generic\BASE\E32\EUSER\epoc\win32\uc_exe.cpp #46> + 12 - 
    
    SilentSMSv4.exe! 246355e2()
    Ordinal274 + 2410 - ekern.exe! 49fa9fd()
    Ordinal454 + 549 - ekern.exe! 49f8da2()
    kernel32.dll! 7c80b729()
    The method code is here. I've tried to delete the dataSupplier in the end, but then I had list with plenty of leaks, not only two Do you see any bugs ?
    Code:
    void CClientEngine::HttpPostL(const TDesC8& aUri, TDesC& aFileName)
      {
    	 // Parse string to URI
    	  TUriParser8 uri;
    	  uri.Parse(aUri);
    
    	  // Copy data to be posted into member variable; iPostData is used later in
    	  // methods inherited from MHTTPDataSupplier.
    	  delete iPostData;
    	  iPostData = 0;
    
    	  // Get request method string for HTTP POST
    	  RStringF method = iSession.StringPool().StringF(HTTP::EPOST, RHTTPSession::GetTable());
    
    	  // Open transaction with previous method and parsed uri. This class will
    	  // receive transaction events in MHFRunL and MHFRunError.
    	  iTransaction = iSession.OpenTransactionL(uri, *this, method);
    
    	  // Set headers for request; user agent, accepted content type and body's
    	  // content type.
    	  LoadFileL(aFileName);  
    	  MakePostPacketL(aFileName);
    	  
    	  RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    	  SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    	  SetHeaderL(hdr, HTTP::EAccept, KAccept);
    	  SetHeaderL(hdr, HTTP::EContentType, KPostContentType);
    
    	  // Set this class as an data supplier. Inherited MHTTPDataSupplier methods
    	  // are called when framework needs to send body data.
    	  MHTTPDataSupplier* dataSupplier = this;
    	  iTransaction.Request().SetBody(*dataSupplier);
    
    	  // Submit the transaction. After this the framework will give transaction
    	  // events via MHFRunL and MHFRunError.
    	  iTransaction.SubmitL();
    	  
    	  iRunning = ETrue;
    	  
    	  #if (DEBUG_APP == 1)	
    		TPtrC logPtr(_L("Occured iTransaction.SubmitL(); iRunning = ETrue; "));
    		Essential::LogL(logPtr);
    	  #endif  	  	 
      }
    Last edited by petr_kovar; 2009-04-23 at 16:07.

Similar Threads

  1. Problem with HTTP POST and certain IAP
    By nvuorio in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2008-07-04, 11:12
  2. Application level roaming in S60 3.2 devices (WLAN <-> GPRS IAP)
    By nly in forum Wired and Wireless interfaces (Closed)
    Replies: 0
    Last Post: 2008-05-14, 14:39
  3. Replies: 1
    Last Post: 2008-05-08, 12:32
  4. filtering application as a recipient?
    By aidj in forum General Messaging
    Replies: 1
    Last Post: 2002-11-12, 06:26
  5. Querying the status over a long time crashes the connector application
    By tuender in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-07-25, 05:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×