Multiple Connections but expect one


#1

When I start a node server I get multiple connection endpoints but expect just one. As a result, I get multiple notifications for one object. Can’t figure out why multiple endpoints were created.

const Realm = require('realm');

// copy your instance URL here
const USER_PATH = '/MyRealmPath'
const SERVER_URL = '//MyRealmServerURL';

async function main() {


    var credentials = Realm.Sync.Credentials.usernamePassword('MyAdmin', 'MyPassword')
    const adminUser = await Realm.Sync.User.login(`https:${SERVER_URL}`, credentials)
    

    Realm.Sync.addListener(`realms:${SERVER_URL}`, adminUser, USER_PATH, 'change', async(changeEvent) => {
    	console.log(changeEvent.changes)

    });
        
}


main()


#2

@NeoGolightly What version of realm-js are you using? How many /MyRealmPath realms are on your ROS? Are you using Partial Sync?

Try adding

Realm.Sync.enableSessionMultiplexing()

directly below your require statement.


#3

When adding Realm.Sync.enableSessionMultiplexing() I just got one connection but still get multiple results for one transaction.

I have one /MyRealmPath which is Partial Sync.

I try to send a notification when a new object is published. But with multiple results I would send multiple notifications to the devices.

My realm-js version is 2.16.2


#4

@NeoGolightly you need to use a regular expression to limit the scope of notifier to the single reference realm instead of the partial realms, like this:

'^/MyRealmPath$'


#5

@NeoGolightly Did this work for you? Would you be able to open a ticket at support.realm.io with a repro case? We’d like to handle this case for you automatically


#6

Ahhh. This works. Thank you! Would be great to find this in your documentation.