diff --git a/bigbluebutton-html5/imports/startup/server/index.js b/bigbluebutton-html5/imports/startup/server/index.js index ce0b3500e9b9cdb3c9397060c0c1c81cfb012f58..a221ba818e436b18de52c8ee3565f3c030d15b8c 100755 --- a/bigbluebutton-html5/imports/startup/server/index.js +++ b/bigbluebutton-html5/imports/startup/server/index.js @@ -15,6 +15,11 @@ import userLeaving from '/imports/api/users/server/methods/userLeaving'; const AVAILABLE_LOCALES = fs.readdirSync('assets/app/locales'); +process.on('uncaughtException', (err) => { + Logger.error(`uncaughtException: ${err}`); + process.exit(1); +}); + Meteor.startup(() => { const APP_CONFIG = Meteor.settings.public.app; const INTERVAL_IN_SETTINGS = (Meteor.settings.public.pingPong.clearUsersInSeconds) * 1000; @@ -33,18 +38,26 @@ Meteor.startup(() => { // Skipping heartbeat, because websocket is sending data if (currentTime - this.ws.lastSentFrameTimestamp < 10000) { - Logger.info('Skipping heartbeat, because websocket is sending data', { - currentTime, - lastSentFrameTimestamp: this.ws.lastSentFrameTimestamp, - userId: this.session.connection._meteorSession.userId, - }); - return; + try { + Logger.info('Skipping heartbeat, because websocket is sending data', { + currentTime, + lastSentFrameTimestamp: this.ws.lastSentFrameTimestamp, + userId: this.session.connection._meteorSession.userId, + }); + return; + } catch (err) { + Logger.error(`Skipping heartbeat error: ${err}`); + } } const supportsHeartbeats = this.ws.ping(null, () => clearTimeout(this.hto_ref)); if (supportsHeartbeats) { this.hto_ref = setTimeout(() => { - Logger.info('Heartbeat timeout', { userId: this.session.connection._meteorSession.userId, sentAt: currentTime, now: new Date().getTime() }); + try { + Logger.info('Heartbeat timeout', { userId: this.session.connection._meteorSession.userId, sentAt: currentTime, now: new Date().getTime() }); + } catch (err) { + Logger.error(`Heartbeat timeout error: ${err}`); + } }, Meteor.server.options.heartbeatTimeout); } else { Logger.error('Unexpected error supportsHeartbeats=false'); @@ -53,17 +66,24 @@ Meteor.startup(() => { // https://github.com/davhani/hagty/blob/6a5c78e9ae5a5e4ade03e747fb4cc8ea2df4be0c/faye-websocket/lib/faye/websocket/api.js#L84-L88 const newSend = function send(data) { - this.lastSentFrameTimestamp = new Date().getTime(); + try { + this.lastSentFrameTimestamp = new Date().getTime(); + + if (this.meteorHeartbeat) { + // Call https://github.com/meteor/meteor/blob/1e7e56eec8414093cd0c1c70750b894069fc972a/packages/ddp-common/heartbeat.js#L80-L88 + this.meteorHeartbeat._seenPacket = true; + if (this.meteorHeartbeat._heartbeatTimeoutHandle) { + this.meteorHeartbeat._clearHeartbeatTimeoutTimer(); + } + } - // Call https://github.com/meteor/meteor/blob/1e7e56eec8414093cd0c1c70750b894069fc972a/packages/ddp-common/heartbeat.js#L80-L88 - this.meteorHeartbeat._seenPacket = true; - if (this.meteorHeartbeat._heartbeatTimeoutHandle) { - this.meteorHeartbeat._clearHeartbeatTimeoutTimer(); + if (this.readyState > 1/* API.OPEN = 1 */) return false; + if (!(data instanceof Buffer)) data = String(data); + return this._driver.messages.write(data); + } catch (err) { + console.error('Error on send data', err); + return false; } - - if (this.readyState > 1/* API.OPEN = 1 */) return false; - if (!(data instanceof Buffer)) data = String(data); - return this._driver.messages.write(data); }; Meteor.setInterval(() => {