Hello meteor community please help with this issue.
I have two projects communicating through DDP. One for the server functionality and other for the client side. My client is connecting to my server this way:
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { DDP } from "meteor/ddp-client";
import { App } from '/imports/ui/App';
const server = Meteor.settings.public["BACKEND_URL"];
const Remote = DDP.connect(server);
// Remote connection
Accounts.connection = Remote;
// Remote.subscribe('allUsers');
Meteor.roles = new Mongo.Collection('roles', {
connection: Remote,
});
Meteor.users = new Mongo.Collection('users', {
connection: Remote,
});
Meteor.startup(() => {
render(<App/>, document.getElementById('react-target'));
});
Tracker.autorun(function () {
var token = localStorage.getItem('Meteor.loginToken');
if (token) {
Session.set('logging', true);
Accounts.loginWithToken(token, function (err) {
Session.set('logging', false);
if (err) console.log(err);
});
}
let handle = Remote.subscribe('_roles');
Session.set('subscribing', true);
if (handle.ready()) {
Session.set('subscribing', false);
}
});
This code allows me to connect to my server, access the users, access the roles, make the login functionality just as if they were together. And I even call my methods remotely with no problem using “Remote.call(’ ')”. The problem is that once logged in, If I open 3 tabs, somewhere a logout is being executed. All the 3 tabs get logged out.
I assume that the accounts object counts how many sessions I have on the client and is not allowing me more than 3. I replicated this issue on a different project and it has the same behavior. Please help.