From c51461da09708a7aa152c5ed199d17337f8eae91 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 6 Feb 2019 10:03:33 +0000 Subject: [PATCH] Merge pull request #1480 from sharelatex/bg-allow-separate-websocket-url allow setting separate wsUrl for websockets GitOrigin-RevId: afd4f441397c6b4b402e342f1dec01c971847a0f --- services/web/app/views/layout.pug | 1 + services/web/config/settings.defaults.coffee | 3 +++ services/web/public/src/ide.js | 1 + services/web/public/src/ide/connection/ConnectionManager.js | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/layout.pug b/services/web/app/views/layout.pug index a5a2c12df5..a73398df38 100644 --- a/services/web/app/views/layout.pug +++ b/services/web/app/views/layout.pug @@ -68,6 +68,7 @@ html( script. window.sharelatex = { siteUrl: '#{settings.siteUrl}', + wsUrl: '#{settings.wsUrl}', jsPath: '#{jsPath}', sixpackDomain: '#{settings.sixpack.domain}' }; diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index 20aed0fdcb..38273160bb 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -188,6 +188,9 @@ module.exports = settings = # that are sent out, generated links, etc. siteUrl : siteUrl = process.env['PUBLIC_URL'] or 'http://localhost:3000' + # Optional separate location for websocket connections, if unset defaults to siteUrl. + wsUrl: process.env['WEBSOCKET_URL'] + # cookie domain # use full domain for cookies to only be accessible from that domain, # replace subdomain with dot to have them accessible on all subdomains diff --git a/services/web/public/src/ide.js b/services/web/public/src/ide.js index 456f686fd3..60a227fa44 100644 --- a/services/web/public/src/ide.js +++ b/services/web/public/src/ide.js @@ -185,6 +185,7 @@ define([ ide.validFileRegex = '^[^*/]*$' // Don't allow * and / + ide.wsUrl = window.sharelatex.wsUrl || null // websocket url (if defined) ide.project_id = $scope.project_id = window.project_id ide.$scope = $scope diff --git a/services/web/public/src/ide/connection/ConnectionManager.js b/services/web/public/src/ide/connection/ConnectionManager.js index d62e054995..b952d4ff44 100644 --- a/services/web/public/src/ide/connection/ConnectionManager.js +++ b/services/web/public/src/ide/connection/ConnectionManager.js @@ -33,6 +33,7 @@ define([], function() { constructor(ide, $scope) { this.ide = ide this.$scope = $scope + this.wsUrl = ide.wsUrl || null // websocket url (if defined) if (typeof io === 'undefined' || io === null) { console.error( 'Socket.io javascript not loaded. Please check that the real-time service is running and accessible.' @@ -94,7 +95,7 @@ define([], function() { }) this.ide.socket = io.connect( - null, + this.wsUrl, { reconnect: false, 'connect timeout': 30 * 1000,