Closed Damnum closed 7 years ago
Are you using Realm on the client device through another SDK as well?
@bigfish24 Yes I'm using the Android SDK to upload the data in the first place. That is just a one time upload for initial data. But that's not on the client device but from an Android simulator.
The app itself uses React Native only.
That's how the initial upload looks like:
SyncCredentials myCredentials = SyncCredentials.usernamePassword(ADMIN_USER, ADMIN_PW, false);
SyncUser user = SyncUser.login(myCredentials, "http://128.xxx.xxx.110:9080/auth");
SyncConfiguration configuration = new SyncConfiguration.Builder(user, REALM_URL)
.name(REALM_FILE_NAME)
.schemaVersion(1)
.build();
Realm managementRealm = user.getManagementRealm();
managementRealm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
PermissionChange change = new PermissionChange(REALM_URL, "*", true, null, null);
realm.insert(change);
}
});
Realm realm = Realm.getInstance(configuration);
//fill realm with data
Version of the Android SDK is 3.0.0
@bigfish24 my suspicion is that the error shows up because of the following: I'm using an Android emulator to test. At the same time I'm using the Realm browser to manipulate data on the same remote database. Is it possible that the sessions get somehow overlapped because I'm running emulator and realm browser from the same network?
After closing the realm explorer, restarting the server, and reinstalling the app, I still get the same error. Is there any documentation on why this error happens exactly?
Hi @Damnum, normally I would expect to see this error in a situation where the server has been cleared and reset but not all the clients. A client then connects to the server attempting to resume a previous session, but the server does not recognize the session identifier — in this particular case, the same session identifier may have been assigned to a different client connecting with a clean slate.
In concrete terms, the error means that the server sees two clients attempting to synchronize using the same session identifier. Please let me know if this explanation fits your scenario. :-)
Turns out, the issue happens because opening the realm file with Realm.openAsync
or Realm.open
creates a new session.
When I refresh the app in the simulator (or kill the app on the device) and restart it, I need to re-open the realm. This is when the error starts to happen on the server side (because a new session is started on the same file). Sync does not happen from this point on.
Is there any way to merge or close sessions manually?
Ok I did some more research. The problem only happens when using the Chrome debugger with React Native. Everything works fine when turning it off. So I'm closing this, since there are multiple tickets open in the realm-js repo related to the Chrome debugger. Thanks for the replies.
Goals
I'm trying to login and open an existing realm with a user that is not the creator of the realm file. The realm has read-only default permissions.
Expected Results
User can open and read the data.
Actual Results
User gets a CONNECTION_REFUSED error on client side.
On server side, the log says:
2017-08-02T10:15:47.561Z - error: sync: Sync Connection[12429]: Session[1]: Client file already bound in other session (message_type='ident', path='/b07f9xxxxxxx5a256bdc7bbb8de7c/app').
Steps to Reproduce
Run js code below (React Native)
Code Sample
Version of Realm and Tooling