From cb58037ea1c2448c97b69ca904ce5836cd32e7de Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Mon, 8 Jul 2019 18:51:34 +0000 Subject: [PATCH] fix crash from invalid online users --- .../imports/api/ping-pong/server/publishers.js | 2 +- .../api/users/server/handlers/validateAuthToken.js | 2 -- .../imports/api/users/server/methods/userLeaving.js | 2 -- bigbluebutton-html5/imports/startup/server/index.js | 13 +++++++------ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/bigbluebutton-html5/imports/api/ping-pong/server/publishers.js b/bigbluebutton-html5/imports/api/ping-pong/server/publishers.js index eed0c25b2c..8963b9ca48 100644 --- a/bigbluebutton-html5/imports/api/ping-pong/server/publishers.js +++ b/bigbluebutton-html5/imports/api/ping-pong/server/publishers.js @@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger'; import _ from 'lodash'; const COLLECTION_NAME = 'ping-pong'; -const POLL_INTERVAL = 5000; +const POLL_INTERVAL = 15000; function pingPong(credentials) { const { meetingId, requesterUserId } = credentials; diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js b/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js index 2f96193c13..e60d924dd0 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js @@ -1,7 +1,6 @@ import { check } from 'meteor/check'; import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -import setConnectionStatus from '/imports/api/users/server/modifiers/setConnectionStatus'; import userJoin from '../methods/userJoin'; const clearOtherSessions = (sessionUserId, current = false) => { @@ -54,7 +53,6 @@ export default function handleValidateAuthToken({ body }, meetingId) { if (valid) { const sessionUserId = `${meetingId}-${userId}`; const currentConnectionId = User.connectionId ? User.connectionId : false; - setConnectionStatus(meetingId, userId); clearOtherSessions(sessionUserId, currentConnectionId); } diff --git a/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js b/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js index 9a4803d0cd..321689b3fd 100755 --- a/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js @@ -3,7 +3,6 @@ import { check } from 'meteor/check'; import RedisPubSub from '/imports/startup/server/redis'; import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -import setConnectionStatus from '/imports/api/users/server/modifiers/setConnectionStatus'; export default function userLeaving(credentials, userId, connectionId) { const REDIS_CONFIG = Meteor.settings.private.redis; @@ -38,6 +37,5 @@ export default function userLeaving(credentials, userId, connectionId) { }; Logger.info(`User '${userId}' is leaving meeting '${meetingId}'`); - setConnectionStatus(meetingId, userId, 'offline'); return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); } diff --git a/bigbluebutton-html5/imports/startup/server/index.js b/bigbluebutton-html5/imports/startup/server/index.js index baa5ccce5d..26f7672f77 100755 --- a/bigbluebutton-html5/imports/startup/server/index.js +++ b/bigbluebutton-html5/imports/startup/server/index.js @@ -11,7 +11,7 @@ import setMinBrowserVersions from './minBrowserVersion'; import userLeaving from '/imports/api/users/server/methods/userLeaving'; const parse = Npm.require('url').parse; -const INTERVAL_TIME = 10000; +const INTERVAL_TIME = 30000; const AVAILABLE_LOCALES = fs.readdirSync('assets/app/locales'); Meteor.startup(() => { @@ -49,19 +49,20 @@ Meteor.startup(() => { Logger.info('Checking for inactive users'); const users = Users.find({ connectionStatus: 'online', + clientType: 'HTML5', lastPing: { $lt: (currentTime - INTERVAL_TIME), // get user who has not pinged in the last 10 seconds }, + loginTime: { + $lt: (currentTime - INTERVAL_TIME), + }, }).fetch(); if (!users.length) return Logger.info('No inactive users'); Logger.info('Removing inactive users'); users.forEach((user) => { - const loginTimeDelta = currentTime - user.loginTime; - const lastPingDelta = currentTime - user.lastPing; + Logger.info(`Detected inactive user, userId:${user.userId}, meetingId:${user.meetingId}`); user.requesterUserId = user.userId; - return loginTimeDelta >= INTERVAL_TIME - && lastPingDelta >= INTERVAL_TIME - && userLeaving(user, user.userId, user.connectionId); + return userLeaving(user, user.userId, user.connectionId); }); return Logger.info('All inactive user have been removed'); }, INTERVAL_TIME);