1

我基于 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 挂钩并显示以下消息:意外错误。

我做错了什么?

4

0 回答 0