Error while creating an connection with wormhole

6 posts / 0 new
Last post
hariprasad
hariprasad's picture
Offline
Joined: 9 Aug 2011
Posts:
Error while creating an connection with wormhole

Hi,
I am trying to connect to one webservice and download data depending on the data received. My program works fine with the normal mosync app, Now I am trying to convert the same to WormHole, but assertion fails.

I/@@@ MoSync( 610): MoSyncWebChromeClient.onJsAlert: Creating Conneection Screen
D/dalvikvm( 73): GREF has increased to 301
W/System.err( 610): java.lang.Exception: MYASSERT failed
W/System.err( 610): at com.mosync.internal.android.MoSyncHelpers.MYASSERT(MoSyncHelpers.java:91)
W/System.err( 610): at com.mosync.internal.android.MoSyncNetwork.getConnectionObject(MoSyncNetwork.java:491)
W/System.err( 610): at com.mosync.internal.android.MoSyncNetwork.maHttpSetRequestHeader(MoSyncNetwork.java:435)
W/System.err( 610): at com.mosync.internal.android.MoSyncThread.maHttpSetRequestHeader(MoSyncThread.java:3063)
W/System.err( 610): at com.mosync.internal.android.MoSyncThread.nativeRun(Native Method)
W/System.err( 610): at com.mosync.internal.android.MoSyncThread.run(MoSyncThread.java:917)
E/@@@ MoSync( 610): BigPhatError created:Error thrown in MYASSERT
W/System.err( 610): java.lang.Exception: Stack Trace
W/System.err( 610): at com.mosync.internal.android.MoSyncHelpers.MYASSERT(MoSyncHelpers.java:92)
W/System.err( 610): at com.mosync.internal.android.MoSyncNetwork.getConnectionObject(MoSyncNetwork.java:491)
W/System.err( 610): at com.mosync.internal.android.MoSyncNetwork.maHttpSetRequestHeader(MoSyncNetwork.java:435)
W/System.err( 610): at com.mosync.internal.android.MoSyncThread.maHttpSetRequestHeader(MoSyncThread.java:3063)
W/System.err( 610): at com.mosync.internal.android.MoSyncThread.nativeRun(Native Method)
W/System.err( 610): at com.mosync.internal.android.MoSyncThread.run(MoSyncThread.java:917)
W/dalvikvm( 610): JNI WARNING: JNI method called with exception raised
W/dalvikvm( 610): in Lcom/mosync/internal/android/MoSyncThread;.nativeRun ()V (NewStringUTF)
W/dalvikvm( 610): Pending exception is:
I/dalvikvm( 610): Lcom/mosync/internal/android/BigPhatError;: Error thrown in MYASSERT
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncHelpers.MYASSERT(MoSyncHelpers.java:92)
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncNetwork.getConnectionObject(MoSyncNetwork.java:491)
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncNetwork.maHttpSetRequestHeader(MoSyncNetwork.java:435)
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncThread.maHttpSetRequestHeader(MoSyncThread.java:3063)
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncThread.nativeRun(Native Method)
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncThread.run(MoSyncThread.java:917)
I/dalvikvm( 610): "Thread-8" prio=5 tid=8 NATIVE
I/dalvikvm( 610): | group="main" sCount=0 dsCount=0 s=N obj=0x44e98468 self=0x116988
I/dalvikvm( 610): | sysTid=618 nice=0 sched=0/0 cgrp=default handle=1193960
I/dalvikvm( 610): | schedstat=( 396212948 456832873 424 )
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncThread.nativeRun(Native Method)
I/dalvikvm( 610): at com.mosync.internal.android.MoSyncThread.run(MoSyncThread.java:917)
I/dalvikvm( 610):
E/dalvikvm( 610): VM aborting
I/DEBUG ( 30): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

what will be the problem?

 

----- code snippets

Main.c

NativeUI::WebView * wView = getWebView();

ratesAvailable = new RateShow(wView, mReq);

if (ratesAvailable == NULL) {
getWebView()->callJS(
"validatePersonalize(false, 'unable to create RateShow')");
}

From RateShow.h

class RateShow: public ConnectionScreenListener, DownloadListener {
public:
RateShow( NativeUI::WebView* View, String Req) :
mwebView(View), request(Req), inConnection(true) {
mConn = NULL;
state = idel;
mwebView->callJS("validatePersonalize(false, 'Creating Conneection Screen')");
lprintfln("Creating Connection Screen\n");
mConn = new ConnectionScreen(mwebView);
lprintfln("Calling Connection start function \n");
mwebView->callJS("validatePersonalize(false, 'Calling Connection start function')");
mConn->start(EXAMPLE_URL, request, this);
imageCounter = 0;
}
...........................

From ConnectionScreen.h
class ConnectionScreen : protected HttpConnectionListener
, XmlListener
, MtxListener
{
public:
ConnectionScreen(NativeUI::WebView* View) : mHttp(this)
,mState(eIdle), mWebView(View)
{
//showInformation();
mPtr = NULL;
mListner = NULL;
mContext = NULL;
mWebView->callJS("validatePersonalize(false, 'In ConnectionScreen Constructor')");
}
...................................

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mikael Kindborg
miki's picture
Offline
Mobile Wizard
Joined: 29 Jun 2010
Posts:

Hi,

The problem seems to be that the connection handle is not valid (does not exist) when maHttpSetRequestHeader is called. Does your code call HttpConnection::setRequestHeader? Is the connection created by then? What happens in the start method? Can you share more of your code?

I wonder about the debug log (logcat), have you built the app in debug mode? Output with lprintfln is only visible when the app is build in debug mode. I would have expected more of your debug print statements to show up in the log.

If it is possible to provide further details, I can assist in finding the problem.

Best regards, Mikael Kindborg

hariprasad
hariprasad's picture
Offline
Joined: 9 Aug 2011
Posts:

Hi Mikael Kindborg

Here is my Start Method

void ConnectionScreen::start(const char* url, String Req,
ConnectionScreenListener* listner) {
sUrl = url;
mReq = Req;
mListner = listner;
if (sRepeat) {
sCount++;
}

if(mHttp.isOpen())
mHttp.close();

char buf[32];
sprintf(buf, "%i", mReq.length());
mHttp.setRequestHeader("Content-Length", buf);
mHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

lprintfln("Creating HTTP connection\n");
mWebView->callJS("validatePersonalize(false, 'Creating HTTP connection')");
int res = mHttp.create(url, HTTP_POST);

if (res < 0) {
lprintfln("http.create fail %i\n", res);
} else {
lprintfln("writing req to HTTP\n");
mWebView->callJS("validatePersonalize(false, 'writing req to HTTP')");
mHttp.write(mReq.c_str(), mReq.length());
}
}

when I tried SetRequestHeader program is terminating....

I/@@@ MoSync( 836): MoSyncWebChromeClient.onJsAlert: trying to set mhttp request header

I/DEBUG ( 30): #15 pc 00054102 /system/lib/libdvm.so

I/DEBUG ( 30): #16 pc 0004825a /system/lib/libdvm.so

I/DEBUG ( 30): #17 pc 0001103c /system/lib/libc.so

I/DEBUG ( 30): #18 pc 00010b20 /system/lib/libc.so

I/DEBUG ( 30):

I/DEBUG ( 30): code around pc:

I/DEBUG ( 30): 8083b140 1861447c 200618a2 e878f7d8 f7d82000

I/DEBUG ( 30): 8083b150 4808e9e4 6bdb5823 d0002b00 4b064798

I/DEBUG ( 30): 8083b160 701c2426 ea5cf7d8 0004ce80 fffe4ae0

I/DEBUG ( 30): 8083b170 fffe801c 00000374 deadd00d b510b40e

I/DEBUG ( 30): 8083b180 4c0a4b09 447bb083 aa05591b 6b5bca02

I/DEBUG ( 30):

I/DEBUG ( 30): code around lr:

I/DEBUG ( 30): afd154a4 b0834a0d 589c447b 26009001 686768a5

I/DEBUG ( 30): afd154b4 220ce008 2b005eab 1c28d003 47889901

I/DEBUG ( 30): afd154c4 35544306 d5f43f01 2c006824 b003d1ee

I/DEBUG ( 30): afd154d4 bdf01c30 0002ae7c 000000d4 1c0fb5f0

I/DEBUG ( 30): afd154e4 43551c3d a904b087 1c16ac01 604d9004

I/DEBUG ( 30):

I/DEBUG ( 30): stack:

I/DEBUG ( 30): 46de6c58 00000015

I/DEBUG ( 30): 46de6c5c afd1453b /system/lib/libc.so

I/DEBUG ( 30): 46de6c60 afd405a0 /system/lib/libc.so

I/DEBUG ( 30): 46de6c64 afd4054c /system/lib/libc.so

I/DEBUG ( 30): 46de6c68 00000000

I/DEBUG ( 30): 46de6c6c afd154c5 /system/lib/libc.so

I/DEBUG ( 30): 46de6c70 00225940 [heap]

I/DEBUG ( 30): 46de6c74 afd1450d /system/lib/libc.so

I/DEBUG ( 30): 46de6c78 fffe6624

I/DEBUG ( 30): 46de6c7c 80887fc4 /system/lib/libdvm.so

I/DEBUG ( 30): 46de6c80 80887fc4 /system/lib/libdvm.so

I/DEBUG ( 30): 46de6c84 00000000

I/DEBUG ( 30): 46de6c88 fffe6624

I/DEBUG ( 30): 46de6c8c afd1456b /system/lib/libc.so

I/DEBUG ( 30): 46de6c90 df002777

I/DEBUG ( 30): 46de6c94 e3a070ad

I/DEBUG ( 30): #00 46de6c98 00000001

I/DEBUG ( 30): 46de6c9c 8082cff9 /system/lib/libdvm.so

I/DEBUG ( 30): #01 46de6ca0 00000001

I/DEBUG ( 30): 46de6ca4 8082d11f /system/lib/libdvm.so

D/Zygote ( 32): Process 836 terminated by signal (11)

Mikael Kindborg
miki's picture
Offline
Mobile Wizard
Joined: 29 Jun 2010
Posts:

Hi,

Is mHttp an instance of class HttpConnection? Make sure mHttp is created before setting the request header, by calling the create method.

This code closes the connection if open and will break setRequestHeader:

if(mHttp.isOpen())
mHttp.close();

You can take a look at the class EasyHttpConnection for inspiration:
https://github.com/divineprog/MoSyncApps/tree/master/JsonServiceConsumerTemplate/EasyConnection

The method EasyHttpConnection::postJsonRequest() creates the connection.

Post again if you run into problems.

Best regards, Mikael

hariprasad
hariprasad's picture
Offline
Joined: 9 Aug 2011
Posts:

Hi Mikael,
Thanks for your support. I moved the setRequestHeader part after http.crate(). it works !!!!

Mikael Kindborg
miki's picture
Offline
Mobile Wizard
Joined: 29 Jun 2010
Posts:

That is great to hear! :)