如何在Android中连接到Realm Amazon EC2实例?

时间:2017-09-25 21:50:10

标签: amazon-ec2 realm realm-mobile-platform realm-object-server realm-java

我创建了一个基于Realm公共AMI的EC2实例:ami-9f1522e4。它似乎工作正常。

我正在尝试使用以下代码连接到Android:

    String authUrl= "realm://54.173.116.160:9080/auth"; // 54.173.116.160 is my instance IPv4 public IP
    String serverURL = "realm://54.173.116.160:9080/~/default";
    final SyncCredentials syncCredentials = SyncCredentials.usernamePassword(myEmail, myPassword, false);

    SyncUser.loginAsync(syncCredentials, authUrl, new SyncUser.Callback() {
        @Override
        public void onSuccess(SyncUser user) {
            final SyncConfiguration syncConfiguration = new SyncConfiguration.Builder(user, serverURL).build();
            realm = Realm.getInstance(syncConfiguration);
        }
        @Override
        public void onError(ObjectServerError error) {
            Log.e("err", error.getErrorMessage());
        }
    });

但是这会触发onError挂钩,并显示以下消息:意外错误。

我做错了什么?

0 个答案:

没有答案