Confused about the URL


#1

I’ve having trouble connecting to the realm server. I’ve read over the documentation, and don’t really understand what’s going on.

I’m getting an invalid URL error when I debug my app. I’ve tried lots of things.

Can someone explain what path is? I’ve tried:

realm://<my-ip>:9080/default
realm://<my-ip>:9080/~/default
realm://<my-ip>:9080
realm://<my-ip>:9080/~/<user-id>

I followed the guide and installed the server on digital ocean so everything has the default settings. I’ve created and account with my email and password.

Could someone please give me an example?

String serverURL = "realm://<my-ip>:9080~/default";
        SyncCredentials myCredentials = SyncCredentials.usernamePassword("testUser", "simplePassword", true);
        SyncUser user = SyncUser.login(myCredentials, serverURL);
        SyncConfiguration config = new SyncConfiguration.Builder(user, serverURL)
                .schemaVersion(42)
                .build();
        // Use the config
        Realm realm = Realm.getInstance(config);

Thanks


#2

Hi,

For login purpose you have to use

String authURL = “http://my.realm-auth-server.com:9080/auth”;
SyncUser user = SyncUser.login(myCredentials, authURL);

Everything else will remain same.

So your final code will be

String serverURL = “realm://my-ip:9080~/default”;
String authURL = “http://my-ip:9080/auth”;
SyncCredentials myCredentials = SyncCredentials.usernamePassword(“testUser”, “simplePassword”, true);
SyncUser user = SyncUser.login(myCredentials, authURL);
SyncConfiguration config = new SyncConfiguration.Builder(user, serverURL)
.schemaVersion(42)
.build();
// Use the config
Realm realm = Realm.getInstance(config);


#3

Thanks for your reply. It’s still not working…

Do I need to replace auth? And what with?

String authURL = "http://my.realm-auth-server.com:9080/**auth**";

#4

Hi,

No need to replace auth.
It’s the endpoint for authentication.

Can you share your stack trace or code snippet?

also ensure that port is accessible, to ensure that just visit your domain. It should serve a page like below