×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Location
    PUNE,INDIA
    Posts
    52

    Unhappy Application Hangs

    Greetings all !
    We are building an application S60 3rd Edn which opens Rsession Object and sends data over GPRS connection at 1 or 2 minute intervals.

    However , our observation is that if GPRS connection is not there , sometimes the aplication hangs .

    Following is the code ( from Nokia Forum only ! ) . Would some advanced soul point us in the right direction of what could be causing the application hang .

    1) We are using HTTPGET

    void CClientEngine::IssueHTTPGetL(const TDesC8& aUri)
    {
    SetupConnectionL();

    // Parse string to URI (as defined in RFC2396)
    TUriParser8 uri;
    uri.Parse(aUri);

    // Get request method string for HTTP GET
    RStringF method = iSession.StringPool().StringF(HTTP::EGET,
    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 and accepted content type
    RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);

    // Submit the transaction. After this the framework will give transaction
    // events via MHFRunL and MHFRunError.
    iTransaction.SubmitL();

    iRunning = ETrue;
    _LIT(KConnecting,"Connecting...");
    iObserver.ClientEvent(KConnecting, 1);
    }

    2) for Every transmission we are creating a session

    void CClientEngine::SetupConnectionL()
    {
    if( iConnectionSetupDone )
    return;

    iConnectionSetupDone = ETrue;

    //open socket server and start the connection
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));

    // open the IAP communications database
    CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);

    // initialize a view
    CCommsDbConnectionPrefTableView* commDBView =
    commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);





    // go to the first record
    commDBView->GotoFirstRecord();
    User::LeaveIfError(commDBView->GotoNextRecord());

    // User::LeaveIfError(commDBView->GotoFirstRecord());

    // Declare a prefTableView Object.
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;

    // read the connection preferences
    commDBView->ReadConnectionPreferenceL(pref);
    TUint32 iapID = pref.iBearer.iIapId;

    // pop and destroy the IAP View
    CleanupStack::PopAndDestroy(commDBView);

    // pop and destroy the database object
    CleanupStack::PopAndDestroy(commDB);

    // Now we have the iap Id. Use it to connect for the connection.
    // Create a connection preference variable.
    TCommDbConnPref connectPref;

    // setup preferences
    connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
    connectPref.SetBearerSet(ECommDbBearerGPRS);
    //Sets the CommDb ID of the IAP to use for this connection
    connectPref.SetIapId(iapID);

    User::LeaveIfError(iConnection.Start(connectPref));

    //set the sessions connection info
    RStringPool strPool = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();

    //to use our socket server and connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,
    RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) );

    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,
    RHTTPSession::GetTable() ),
    THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))) );
    }



    3) after every transation we are destroying the object

    iClient->CancelTransaction();
    delete (iClient);
    iClient = CClientEngine::NewL(*iAppView);

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Banglore,India
    Posts
    64

    Re: Application Hangs

    I suppose its stopping at SetupconnectionL() if it is not finding access point.
    if so,you can try

    TInt err = iConnection.Start(connectPref);
    if(err != KErrNone)
    {
    iConnectionSetupDone = EFalse;
    iConnection.Close();
    iSocketServ.Close();
    iTransaction.Close();
    }

  3. #3
    Regular Contributor
    Join Date
    Oct 2007
    Location
    PUNE,INDIA
    Posts
    52

    Re: Application Hangs

    Thanks Dattanand.
    but if i need to insert the code in setupconnectionL
    Code:
    void CClientEngine::SetupConnectionL()
    {
    if( iConnectionSetupDone )
    TInt err = iConnection.Start();
        if(err != KErrNone)
        	{
           	iConnectionSetupDone = EFalse;
            iConnection.Close();
            iSocketServ.Close();
       	iTransaction.Close();
        	}
    It works for 1 iteration but the phone hangs for the very next iteration.

  4. #4
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Banglore,India
    Posts
    64

    Re: Application Hangs

    Are you getting IAP selection popup in consecutive iterations?
    if no,then it is trying to use the previously established connection and not trying to reconnect. try calling destructor of your engine where you are handling the error.

  5. #5
    Regular Contributor
    Join Date
    Oct 2007
    Location
    PUNE,INDIA
    Posts
    52

    Re: Application Hangs

    Thanks
    Now neither the phone hangs nor the application. It is also not prompting for selection of access point. but i am getting the error message "PACKET DATA NOT AVAILABLE.PLEASE CHECK NETWORK SERVICES"this message is flashing quite often. i call IssueHTTPGetL every 1 min i.e. i want to send the data every 1 min and it happens that the application sends the data for some time say 4 transmissions. Then flashes error for other 2-3 transmissions. Then it resends some more transmissions and so on. The behaivior is not uniform.
    Before inserting
    Code:
    TInt err = iConnection.Start(connectPref);
    if(err != KErrNone)
    {
    iConnectionSetupDone = EFalse;
    iConnection.Close();
    iSocketServ.Close();
    iTransaction.Close();
    }
    i never got this error and the application use to send data by IssueHTTPGetL continuously,at times, even for 2 days


    My questions:
    1. Is it some error that is uncaught in the application which is causing this OR is it error at network?
    2. Can i suppress the error message that is flashing so user does not know about the error?

Similar Threads

  1. Launching a dialog when the application starts
    By Uriah Eisenstein in forum Symbian User Interface
    Replies: 10
    Last Post: 2009-03-31, 09:06
  2. Launching a view of a diffrent application
    By nsivach in forum Symbian
    Replies: 3
    Last Post: 2007-03-22, 09:51
  3. Bringing application to foreground
    By ash_bhatia in forum Symbian User Interface
    Replies: 1
    Last Post: 2006-11-02, 13:39
  4. Application hangs randomly
    By lmtang in forum Mobile Java General
    Replies: 10
    Last Post: 2005-07-12, 02:59
  5. Replies: 0
    Last Post: 2005-05-28, 10:20

Posting Permissions

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