Realm.open(config) using nodeJs errorCode: 125


#1

I am trying to connect to cloud instance via nodeJs. On windows I get a ‘make dir() failed: no such file or directory’ (same as realm-js, issue 2097)

if I try it from a debian linux host (on top of windows linux service) I get
{ message: ‘Operation canceled’, errorCode: 125 }

I tried serveral configuration for sync but I keep getting the same error. The user I use to login is administrator en I am able to login with that user via realm studio.

The error occurs in Realm.open(config). Authentication of the user is succesfull.

The serverlog (via realm studio) shows a message with:
{“type”:“https://realm.io/docs/object-server/problems/missing-parameters",“title”:"Your request did not validate because of missing parameters.”,“status”:400,“code”:602,“invalid_params”:[{“name”:“token”,“reason”:“Missing parameter ‘token’!”}]}

I use node v10.15 and realm 2.21.1 via npm .

Does anybody know what I am doing wrong?

here is the code I use :

const Realm = require('realm');
const constants = require('./constants.js');

function main () {

 const Client = {
    name: "Client",
    primaryKey: "clientId",
    properties: {
      clientId: "string",
      firstname: "string",
      lastname: "string",
    }
  };

 Realm.Sync.setLogLevel('trace');

 const creds = Realm.Sync.Credentials.usernamePassword(constants.username, constants.password, false);

 console.log(constants.serverUrl);
 console.log(creds);


 Realm.Sync.User.login(`https://${constants.serverUrl}`, creds)
    .then((user) => {
        let configuration = {
                sync: { user: user,
                        error: (err) => {console.log('err opening sync: ' + err);},
                        //url: `realms://${constants.serverUrl}`,
                        fullSynchronization: false,
                        ssl: {validate: true},
          },
        schema: [Client],
        };


        let config = user.createConfiguration(configuration);
        //console.log(config);
        Realm.open(config)
            .then(realm => {
                console.log('we have a realm!!');
                // Query Realm for all client
                const clients = realm.objects('Client');

                // Will return a Results object with our 1 car
                console.error(clients.length); // => 1


            })
            .catch((error) => {
                console.error('shit, we have an error:', error);
            });
        user.logout();
    })
    .catch((error) => {
        console.error('Login error:', error);
   });
//end of main
}

main();

#2

@avanschijndel You need a sync.url parameter in your syncConfig that has a valid Realm path, for example:

realms://myRealmCloud.com/myRealm

As documented here - https://docs.realm.io/sync/using-synced-realms/setting-up-your-realms#how-to-open-a-realm


#3

@ianward thanks for your response. I did add the realm to sync (default) to the sync props (again), but still get the same error: ‘operation cancelled’, errorcode: 125.

When I try to run de nodeJs script, I stil get the following error:

  • Your request did not validate because of missing parameters: Missing parameter ‘token’!

Do you know which token this log is referring to?


#4

@avanschijndel Can you wipe the local state and retry please?

rm -rf realm-object-server

If that doesn’t work please open a ticket at support.realm.io with a repro and we will get you sorted


#5

thanks for your answer. removing the realm-object-server directory and subdirs gives the same errorcode. I did open a ticket at support.realm.io.