Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

SyncParms sp = _conn.createSyncParms(SyncParms.HTTPS_STREAM, "ml_username", "script_version");
StreamHTTPSParms streamParms = (StreamHTTPSParms) syncParms.getStreamParms();
streamParms.setHost( host );
streamParms.setPort( port );
_conn.synchronize(sp);

I have started my MobiLink server correctly:

<Main> https.2500: RSA_TLS: This secure stream is being encrypted using security technology from Certicom Corp.
<Main> This software is using security technology from Certicom Corp.
<Main> MobiLink server started

If I try to connect to the ML server through my android app I get Error code 224. (I have no problems connecting through HTTP)

asked 22 Aug '11, 11:35

sebastiansier's gravatar image

sebastiansier
1112
accept rate: 0%

edited 22 Aug '11, 14:24

Graeme%20Perrow's gravatar image

Graeme Perrow
9.6k379124


Error code 224 is "Failed to load library" (see here).

It looks like you need to include the library libmlcrsa12.so in the same folder as the UltraLite library (the libsarmeabi subdirectory of your project). You can find libmlcrsa12.so in the UltraLite\UltraLiteJ\Android\ARM subdirectory of your SQL Anywhere application.

If you have any issues with certificates for HTTPS, you may find something in a recent blog post on the subject: see here.

permanent link

answered 22 Aug '11, 11:49

Tom%20Slee's gravatar image

Tom Slee
1.3k21629
accept rate: 29%

edited 22 Aug '11, 11:50

In my project, I have the library libmlcrsa12.so in my libs/armeabi folder. When I deploy my project to the emulator I found the libmlcrsa12.so and libultralitej12.so under data/data/<my-project-package>/lib/

I've also created my HTTPS certificates and started my MobiLink server correctly, but still can't connect through my app.

Thanks for your help.

(22 Aug '11, 12:03) sebastiansier

Are you still getting Error Code 224? As I say, that's "Failed to load library". If it's not a missing library, then I am not sure what would be causing it.

(22 Aug '11, 15:47) Tom Slee

Yes, i am still getting error code 224. The library is not missing, it is just not loading.

(22 Aug '11, 16:54) sebastiansier

The next thing to verify is that the 2nd parameter to DatabaseManager.createConfigurationFileAndroid() is a valid Context object. Eg.

ConfigFileAndroid config = DatabaseManager.createConfigurationFileAndroid(
        "test.udb",
        getApplicationContext());
permanent link

answered 22 Aug '11, 13:47

Andy%20Quick's gravatar image

Andy Quick
2.2k2737
accept rate: 45%

When executing DatabaseManager.createConfigurationFileAndroid the second parameter has the value: android.app.Application@44ef4458 (I can see this in debug mode). Also, when executing the same code but trying to connect to an HTTP server i have no problems, so I asume it is a valid context object. Any other suggestions?

(22 Aug '11, 13:58) sebastiansier

Everything seems right. You say you are using the Android emulator? Which platform are you targetting? Can you give a small test program that reproduces the error? Thanks.

(22 Aug '11, 17:10) Andy Quick

I modified our custdb sample to use HTTPS data sync (pasting in some of the code you provided), but still could not reproduce the problem.

It occurs to me that it could be the MobiLink server that could not find a library. Where do you see the error message with code 224? In the ML server log? A ULjException in the client application? Also, please give us the exact text of the error message.

The below is the ULjException that I get in the custdb application if I manually remove libmlcrsa12.so from the emulator:

08-24 10:50:08.448: ERROR/CustDB(273): com.ianywhere.ultralitejni12.implementation.JniException: UltraLiteJ Error[-1305]: MobiLink communication error -- code: 224, parameter: libmlcrsa12.so, system code: 0

(24 Aug '11, 11:08) Andy Quick

The error is the same as you posted:

com.ianywhere.ultralitejni12.implementation.JniException: UltraLiteJ Error[-1305]: MobiLink communication error -- code: 224, parameter: libmlcrsa12.so, system code: 0

but I have data/data/<package>/lib/libmlcrsa12.so in the emulator.

(24 Aug '11, 13:15) sebastiansier

I am almost out of ideas. You could check that the libmlcrsa12.so that is in the emulator is byte-for-byte the same as the one in the SQL Anywhere install.

If that is the case, the only other thing is that something in your application is different from the applications we use to test with. Could you package up a complete Eclipse project that shows the problem? (eg. using the ML server command line for our custdb sample, with the sample rasroot.crt in the install) If we can reproduce the problem, then we can fix it. Thanks.

(24 Aug '11, 14:06) Andy Quick

PS You can email me the sample Eclipse project at firstname.lastname [at] sybase.com

Andy Quick Sybase, an SAP company

(24 Aug '11, 14:08) Andy Quick

Sebastian - We cannot reproduce this issue here: our samples using HTTPS do work. You could test your environment by trying the CustDB sample included with SQL Anywhere and changing StreamHTTPParms to StreamHTTPSParms, to see if that project works for you. Otherwise, emailing the project as suggested or opening a tech support case look like the ways forward.

(25 Aug '11, 14:42) Tom Slee
More comments hidden
showing 5 of 7 show all flat view

Here is my code:

Connection _conn;
ConfigPersistent _config;

public void onCreate(Bundle savedInstanceState) {
    try{
        super.onCreate(savedInstanceState);

    InputStream is = getResources().openRawResource(R.raw.cert);
    FileOutputStream os = openFileOutput("cert.pem", MODE_PRIVATE);
    byte[] buff = new byte[4096];
    int n;
    for(;;) {
        n = is.read(buff);
    if (n < 0) break;
    os.write(buff, 0, n);
    }

        _config = DatabaseManager.createConfigurationFileAndroid("DATABASE_NAME", getApplicationContext());
        _config.setLazyLoadIndexes(true);
        _conn = DatabaseManager.connect(_config);
        _conn = DatabaseManager.connect(_config);

        SyncParms syncParms = _conn.createSyncParms(SyncParms.HTTPS_STREAM,_user,_version );
    syncParms.setPassword("passwordd");

        StreamHTTPSParms streamParms = (StreamHTTPSParms) syncParms.getStreamParms();
    streamParms.setHost( _host );
    streamParms.setPort( _port );
    streamParms.setTrustedCertificates("/data/data/<package>/files/cert.pem");
        _conn.synchronize( syncParms );
    } catch (Exception e) {
        e.printStackTrace();
    }
}

I am using an Android 2.2 emulator.
Thanks for your help.

permanent link

answered 23 Aug '11, 09:23

sebastiansier's gravatar image

sebastiansier
1112
accept rate: 0%

edited 24 Aug '11, 13:02

1

One thing I notice in this code fragment is that the ConfigFileAndroid object that is returned by DatabaseManager.createConfigurationFileAndroid() is not stored in a variable. You must actually pass this object as an argument to DatabaseManager.createDatabase() or connect(). Using a ConfigPersistent object that was created without going through createConfigurationFileAndroid() would cause a problem like this.

(24 Aug '11, 11:56) Andy Quick

I edited the code, i was actually doing what you say ... buy still get the error.

(24 Aug '11, 13:09) sebastiansier
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×371
×79

question asked: 22 Aug '11, 11:35

question was seen: 4,197 times

last updated: 25 Aug '11, 14:42