cancel
Showing results for 
Search instead for 
Did you mean: 

Android app registration in SUP without Relay Server fails

0 Kudos

Hi all,

I am trying to register a native Android app without usage of a Relay Server but the connection to the SUP fails due to some Relay Server URL Template. This is an excerpt from the console: 

registerApplication

com.sybase.mobile.ApplicationRuntimeException: Could not connect to server. Verify Relay Server URL Template

     at com.sybase.sup.client.mbs.SupHandler.pingMessagingServer(SupHandler.java:162)

     at com.sybase.mobile.Application$1.run(Application.java:376)

Caused by: Error: 558 Message: 'Could not connect to server. Verify Relay Server URL Template'

     at com.sybase.mo.MoObject.ConvertTmExceptionToMoException(MoObject.java:868)

     at com.sybase.mo.MoObject.execute(MoObject.java:683)

     at com.sybase.sup.client.mbs.SupMoObject.sendMessageToServer(SupHandler.java:787)

     at com.sybase.sup.client.mbs.SupHandler.pingMessagingServer(SupHandler.java:157)

My device is in the same local network as the SUP server.

This is the application code:

Application app = Application.getInstance();

app.setApplicationIdentifier("submobileapp");

ApplicationCallback appCallback = new DefaultApplicationCallback();

app.setApplicationCallback(appCallback);

app.setApplicationContext(getApplicationContext());

SUBMobileAppDB.setApplication(app);

SUBMobileAppDB.initialize();

ConnectionProperties connProps = app.getConnectionProperties();

connProps.setServerName("mySUP");

connProps.setPortNumber(5001);

connProps.setActivationCode("abc");

connProps.setFarmId("0");

connProps.setSecurityConfiguration("admin");


LoginCredentials loginCred = new LoginCredentials("supAdmin", "supAdmin");

connProps.setLoginCredentials(loginCred);


if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED) {

     app.registerApplication(100); // this is where the error occurs

     connProps.setActivationCode("abc");

} else {       

     app.startConnection(100);

}

ConnectionProfile connProfile = SUBMobileAppDB.getConnectionProfile();

connProfile.setProperty("databaseFile", android.os.Environment.getExternalStorageDirectory().getPath());

connProfile.setEncryptionKey("encryption key must be 16 characters or longer");

connProfile.setCacheSize(102400);

connProfile.save();


ConnectionProfile cp = SUBMobileAppDB.getSynchronizationProfile();

cp.setServerName("mySUP");

cp.setPortNumber(2480);       

cp.setAsyncReplay(true);

cp.setNetworkProtocol("http");

cp.setDomainName("default");

cp.save();


if (!SUBMobileAppDB.databaseExists()) {

     SUBMobileAppDB.createDatabase();

}

SUBMobileAppDB.openConnection();

SUBMobileAppDB.synchronize("system");

SUBMobileAppDB.synchronize();

Can anyone give me a hint what might be wrong?

Cheers,

Marcus

Accepted Solutions (1)

Accepted Solutions (1)

rakshit_doshi
Active Contributor
0 Kudos

Hi Marcus,

What is the mySUP in the host name. If you are keeping your device in the same domain as the server then the local ip of the server will work but in case your device is outside the domain in which the server is installed either you will require a relay server or have to make the local ip where the  SUP Server is installed as the public ip.

I dont see anything wrong in your code.

What i am assuming is you are trying to access the server from outside with the local ip which will never happen.

And instead of giving the server name as mySUP its better you give the IP Address.

Hope this helps.

Thanks

0 Kudos

Hi Rakshit,

I guess using the IP address instead of the hostname is a good idea but it still does not work. Is it possible that this depends somehow on the android permissions that have to be set in the MANIFEST file? What kind of permissions do I need here?

Cheers,

Marcus

Former Member
0 Kudos

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

0 Kudos

Hi Nigel,

that's it 🙂 The INTERNET permission was missing and I didn't recognize it before. Now it works.

Thanks a lot.

Marcus

Former Member
0 Kudos

CHEERS!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Marcus,

am not sure what is wrong in your code.

but am sharing mine below....m currently using dis code and it works....

let me know if you have any questions

//-----------------------Credentials---------------------------    

     private static String USERNAME = "supAdmin";

    private static String PASSWORD = "s3pAdmin";

    private static String HOST = "172.17.110.108";

    private static int PORT = 5001;

    private static int TIMEOUT = 600;

//---------------------Registration and Synchronization ---------------

Application app = Application.getInstance();

        if (app.getApplicationIdentifier() == null)

            app.setApplicationIdentifier("AndroidSUPDemo");

        app.setApplicationContext(AndroidDemoActivity.this);

       

   

        new Thread(new Runnable() {

            public void run() {

                try {

                    AndroidSUPDemoDB.setApplication(app);

                    AndroidSUPDemoDB.getSynchronizationProfile().setServerName(HOST);

                    LoginCredentials loginCredentials = new LoginCredentials(

                            USERNAME, PASSWORD);

                    ConnectionProperties connProps = app

                            .getConnectionProperties();

                    connProps.setLoginCredentials(loginCredentials);

                    connProps.setServerName(HOST);

                    connProps.setPortNumber(PORT);

                    if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED) {

                        app.registerApplication(TIMEOUT);

                    } else {

                        app.startConnection(TIMEOUT);

                    }

                    if (!AndroidSUPDemoDB.isSynchronized("default")) {

                        AndroidSUPDemoDB.disableChangeLog();

                       

                        AndroidSUPDemoDB.synchronize(); // Initial

                                                                // Synchronize

                      

                        SynchronizationGroup sg = AndroidSUPDemoDB

                                .getSynchronizationGroup("default");

                        sg.setEnableSIS(true);

                        sg.save();

                        AndroidSUPDemoDB

                                .synchronize();

                    }