Using RHTTPSession on Nokia 9500 freezes display

Login to reply to this topic.
Thu, 2005-02-03 14:28
Joined: 2004-05-26
Forum posts: 73
I have an application on the Nokia 9500 which performs a long process in a number of steps. A CIdle object determines when to execute the next step. One of these steps sends and retrieves data from a webservice. But.. in about 50% of the runs, the application panics with a ViewSrv 11 after making the connection.

I use the RHttpSession and RHttpTransaction classes to make the connection and to retrieve the data. The CIdle object runs with priority 'low' (I also tried 'idle', which had the same result). Right before returning ETrue to the CIdle object, I wait a while with User::After(5000), thinking this might solve the problem, but it didn't.

What I see in the log files, is that:
- the connection is being made and the transaction started
- the CIdle callback function returns with a value of ETrue, telling the CIdle object that there is more work to be done

..and that's it. In about half of the cases, the CIdle object never gets activated again.

I created a small test program to demonstrate the problem. You can download a zip file containing the sources, a package file and an installation file for the Nokia 9500 at:

http://www.powerjuice.nl/NokiaTest.zip

The core is the CNokiaTest class.
Header:
Code:
// CNokiaTest.h
// Test class for Nokia 9500 HTTP connection.

#ifndef __CNOKIATEST_H
#define __CNOKIATEST_H

class CIdle;
#include <http/rhttpsession.h>
#include <http/mhttptransactioncallback.h>
#include <http/mhttpdatasupplier.h>

class CNokiaTest :
public CBase,
public MHTTPTransactionCallback,
public MHTTPDataSupplier

{
public:
static CNokiaTest* NewL();
~CNokiaTest();

void StartL();

static TInt IdleCallback(TAny *aPtr);

// Implementation of MHTTPTransactionCallBack interface
void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);

// Implementation of MHTTPDataSupplier interface
TBool GetNextDataPart(TPtrC8& aDataPart) { aDataPart.Set(KNullDesC8); return(ETrue); }
void ReleaseData() {}
TInt OverallDataSize() { return 0; }
TInt Reset() { return KErrNone; }

private:
CNokiaTest();
void ConstructL();

void StartHttpConnectionL();
TInt CheckConnection();

CIdle* iIdle;
RHTTPSession iSession;
RHTTPTransaction iTransaction;
TBool iConnClosed;
TPtrC iMsgPtr;
};

#endif // #ifndef __CNOKIATEST_H

And cpp file:
Code:
// CNokiaTest.cpp

#include <e32base.h>
#include <eikenv.h>
#include <http/rhttpsession.h>
#include <HttpStringConstants.h>
#include <http/rhttpheaders.h>

#include "CNokiaTest.h"

_LIT(KConnIdle, "Idle");
_LIT(KConnInit, "Initializing");
_LIT(KConnConnecting, "Connecting");
_LIT(KConnResponse, "Got response");
_LIT(KConnResponseComplete, "Response complete");
_LIT(KConnClosed, "Connection closed");
_LIT(KConnFailed, "Connection failed");
_LIT(KConnError, "Connection error");
_LIT(KConnUnhandled, "Unhandled event");

CNokiaTest::CNokiaTest() :
iIdle(NULL),
iConnClosed(EFalse),
iMsgPtr(KConnIdle)
{
}

CNokiaTest::~CNokiaTest()
{
delete iIdle;
iSession.Close();
}

CNokiaTest* CNokiaTest::NewL()
{
CNokiaTest* result = new(ELeave) CNokiaTest();
CleanupStack::PushL(result);
result->ConstructL();
CleanupStack::Pop(result);

return result;
}

void CNokiaTest::ConstructL()
{
iIdle = CIdle::NewL(CActive::EPriorityIdle);
iSession.OpenL();
}

void CNokiaTest::StartL()
{
// Start the HTTP connection; then start the idle AO.
StartHttpConnectionL();

iIdle->Start(TCallBack(IdleCallback, this));
}

void CNokiaTest::StartHttpConnectionL()
{
_LIT8(KUrl, "http://www.powerjuice.nl");
_LIT8(KContentType, "text/html");

iConnClosed = EFalse;
iMsgPtr.Set(KConnInit);

RStringPool string_pool = iSession.StringPool();
RStringF method = string_pool.StringF(HTTP::EPOST, RHTTPSession::GetTable());
TUriParser8 uri;
uri.Parse(KUrl);
iTransaction = iSession.OpenTransactionL(uri, *this, method);

RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
RStringF cont_type_str = string_pool.OpenFStringL(KContentType);
THTTPHdrVal cont_type(cont_type_str);
hdr.SetFieldL(string_pool.StringF(HTTP::EContentType,RHTTPSession::GetTable()), cont_type);
cont_type_str.Close();

iTransaction.Request().SetBody(*this);

iTransaction.SubmitL();
iMsgPtr.Set(KConnConnecting);
}

TInt CNokiaTest::IdleCallback(TAny *aPtr)
{
CNokiaTest* test_obj = static_cast<CNokiaTest*>(aPtr);
return test_obj->CheckConnection();
}

TInt CNokiaTest::CheckConnection()
{
TRAPD(err, CEikonEnv::Static()->BusyMsgL(iMsgPtr));
return (!iConnClosed);
}

void CNokiaTest::MHFRunL(RHTTPTransaction /* aTransaction */, const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
case THTTPEvent::EGotResponseBodyData:
iMsgPtr.Set(KConnResponse);
break;

case THTTPEvent::EResponseComplete:
iMsgPtr.Set(KConnResponseComplete);
break;

case THTTPEvent::ESucceeded:
iMsgPtr.Set(KConnClosed);
iTransaction.Close();
iConnClosed = ETrue;
break;

case THTTPEvent::EFailed:
iMsgPtr.Set(KConnFailed);
iTransaction.Close();
iConnClosed = ETrue;
break;

default:
{
iMsgPtr.Set(KConnUnhandled);
// Stop the transaction handling in case of error
if (aEvent.iStatus < 0)
{
iTransaction.Close();
iConnClosed = ETrue;
}
}
break;
}
}

TInt CNokiaTest::MHFRunError(TInt /*aError*/, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
{
iMsgPtr.Set(KConnError);
return KErrNone;
}

After making a connection, the display freezes for more than 20 seconds, which is enough for the View Server to panic.

It should not freeze. This looks to be a bug in the HTTP server implementation on the Nokia 9500..

Thu, 2005-04-14 15:56
Joined: 2005-01-13
Forum posts: 31
Using RHTTPSession on Nokia 9500 freezes display
Quote
  // Implementation of MHTTPDataSupplier interface
   TBool GetNextDataPart(TPtrC8& aDataPart) { aDataPart.Set(KNullDesC8); return(ETrue); }
   void ReleaseData() {}
   TInt OverallDataSize() { return 0; }
   TInt Reset() { return KErrNone; }
Try to actually sending something, rather then empty pointer. I don't know, but tha could be the problem - Symbian is strange sometimes.

Wed, 2005-07-27 16:35
Joined: 2005-07-07
Forum posts: 34
Re: Using RHTTPSession on Nokia 9500 freezes display
Hi arno,

I have try to test your code, but I have a follwing problem:

I want automaticly send data when i make connection - without Dialog for choise of connection type. I use:

TCommDbConnPref pref;
pref.SetIapId(1);
pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
TRequestStatus status;
iConnection.Start(pref);

but there is again ECommDialog ?

Thanks
Thu, 2005-08-18 10:45
Joined: 2005-02-11
Forum posts: 214
Re: Using RHTTPSession on Nokia 9500 freezes display
I have it working in 9500 without problems - no freezing

"I only know that I know nothing." (Socrates)

Thu, 2005-08-18 13:12
Joined: 2005-01-13
Forum posts: 31
Re: Using RHTTPSession on Nokia 9500 freezes display
Thanks riho, so now when You've made it working, everybody can sleep well at night. Next time, just post the solution, dude.
Anyway, connectiong over RSocket, has been working, but I don't know if that's a setting you do or if it has something to do with signing the application. I'm quite sure it's impossible using the HTTP API's on Series 80, but I might be wrong there. If you solved the problem, please post the full solution, nobody cares if you did, unless you share.

Anyway, while working on Symbian OS 9.x (EKA2) the plattform security and the Symbian Signed program doesn't allow implicit connections - the user has to be aware that the phone is connection. This doesn't mean that you have to pop the IAP dialog. You can get a capability so that the IAP isn't nessesary, but you'll still have to inform the user that a connection is being made, otherwise you won't pass the test.

Thu, 2005-08-18 13:18
Joined: 2005-02-11
Forum posts: 214
Re: Using RHTTPSession on Nokia 9500 freezes display
Use Nokia's HTTPExample. I took this as a base for my needs. For 9500 you have to throw away the UI part.

"I only know that I know nothing." (Socrates)

  • Login to reply to this topic.