From 8e61bccbba1d58d478fcfcb1ea99a76c1a9a231b Mon Sep 17 00:00:00 2001 From: ph4z Date: Wed, 20 Oct 2021 11:07:52 +0000 Subject: [PATCH 1/2] initial support for https clients --- Platform/UI/Data-Files/DailyFiles.js | 4 ++-- Platform/UI/Data-Files/FileCloud.js | 4 ++-- Platform/UI/Data-Files/FileStorage.js | 4 ++-- Platform/UI/Data-Files/MarketFiles.js | 5 +++-- Platform/UI/ProductStorage.js | 10 +++++----- .../UI/Spaces/Charting-Space/PlottersManager.js | 10 +++++++++- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Platform/UI/Data-Files/DailyFiles.js b/Platform/UI/Data-Files/DailyFiles.js index bc810aaef..20bf00dff 100644 --- a/Platform/UI/Data-Files/DailyFiles.js +++ b/Platform/UI/Data-Files/DailyFiles.js @@ -45,7 +45,7 @@ function newDailyFiles() { } } - function initialize(pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pDatetime, pTimeFrame, pHost, pPort, pEventsServerClient, callBackFunction) { + function initialize(pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pDatetime, pTimeFrame, pHost, pPort, pEventsServerClient, callBackFunction, scheme='http') { try { callBackWhenFileReceived = callBackFunction @@ -55,7 +55,7 @@ function newDailyFiles() { let timeFrames fileCloud = newFileCloud() - fileCloud.initialize(pBot, pHost, pPort) + fileCloud.initialize(pBot, pHost, pPort, scheme) /* Config Validations */ if (pDataset.config.validTimeFrames === undefined) { diff --git a/Platform/UI/Data-Files/FileCloud.js b/Platform/UI/Data-Files/FileCloud.js index 2af66ea6a..37df7b05a 100644 --- a/Platform/UI/Data-Files/FileCloud.js +++ b/Platform/UI/Data-Files/FileCloud.js @@ -17,8 +17,8 @@ function newFileCloud () { let fileStorage return thisObject - function initialize (pBot, pHost, pPort) { - fileStorage = newFileStorage(pHost, pPort) + function initialize (pBot, pHost, pPort, scheme='http') { + fileStorage = newFileStorage(pHost, pPort, scheme) } function getFile (pMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, ptimeFrameLabel, pDatetime, pSequence, pDataRange, pTimeFrames, callBackFunction) { diff --git a/Platform/UI/Data-Files/FileStorage.js b/Platform/UI/Data-Files/FileStorage.js index e7421af1e..d865567aa 100644 --- a/Platform/UI/Data-Files/FileStorage.js +++ b/Platform/UI/Data-Files/FileStorage.js @@ -1,4 +1,4 @@ -function newFileStorage(host, port) { +function newFileStorage(host, port, scheme='http') { const MODULE_NAME = 'File Storage' const INFO_LOG = false const logger = newWebDebugLog() @@ -40,7 +40,7 @@ function newFileStorage(host, port) { let url if (host !== undefined && port !== undefined) { - url = 'http://' + host + ':' + port + '/' + folder + filePath + url = scheme + '://' + host + ':' + port + '/' + folder + filePath } else { url = folder + filePath } diff --git a/Platform/UI/Data-Files/MarketFiles.js b/Platform/UI/Data-Files/MarketFiles.js index 0bee471de..80ab45946 100644 --- a/Platform/UI/Data-Files/MarketFiles.js +++ b/Platform/UI/Data-Files/MarketFiles.js @@ -80,7 +80,8 @@ function newMarketFiles() { pHost, pPort, pEventsServerClient, - callBackFunction) { + callBackFunction, + scheme='http') { try { let timeFrames @@ -94,7 +95,7 @@ function newMarketFiles() { eventsServerClient = pEventsServerClient fileCloud = newFileCloud() - fileCloud.initialize(pBot, pHost, pPort) + fileCloud.initialize(pBot, pHost, pPort, scheme) /* Some Validations */ if (dataset.config.validTimeFrames === undefined) { diff --git a/Platform/UI/ProductStorage.js b/Platform/UI/ProductStorage.js index a7f4841cb..ad44db9bf 100644 --- a/Platform/UI/ProductStorage.js +++ b/Platform/UI/ProductStorage.js @@ -74,7 +74,7 @@ function newProductStorage(name) { } } - function initialize(mine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, callBackFunction) { + function initialize(mine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, callBackFunction, scheme='http') { try { datetime = pDatetime timeFrame = pTimeFrame @@ -90,7 +90,7 @@ function newProductStorage(name) { dataSetsToLoad++ let marketFiles = newMarketFiles() - marketFiles.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onMarketFileReady) + marketFiles.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onMarketFileReady, scheme) thisObject.marketFiles.push(marketFiles) } break @@ -99,7 +99,7 @@ function newProductStorage(name) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(mine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, onDailyFileReady) + dailyFiles.initialize(mine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, onDailyFileReady, scheme) thisObject.dailyFiles.push(dailyFiles) } break @@ -108,7 +108,7 @@ function newProductStorage(name) { dataSetsToLoad++ let singleFile = newSingleFile() - singleFile.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onSingleFileReady) + singleFile.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onSingleFileReady, scheme) thisObject.singleFile.push(singleFile) } break @@ -117,7 +117,7 @@ function newProductStorage(name) { dataSetsToLoad++ let fileSequences = newFileSequence() - fileSequences.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onFileSequenceReady) + fileSequences.initialize(mine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onFileSequenceReady, scheme) thisObject.fileSequences.push(fileSequences) } break diff --git a/Projects/Foundations/UI/Spaces/Charting-Space/PlottersManager.js b/Projects/Foundations/UI/Spaces/Charting-Space/PlottersManager.js index 0a0420d56..39d1955e8 100644 --- a/Projects/Foundations/UI/Spaces/Charting-Space/PlottersManager.js +++ b/Projects/Foundations/UI/Spaces/Charting-Space/PlottersManager.js @@ -173,8 +173,15 @@ function newPlottersManager() { let host = layer.lanNetworkNode.config.host let webPort = layer.lanNetworkNode.config.webPort + let extWSURL = layer.lanNetworkNode.config.webSocketsExternalURL + let scheme = 'http' if (host === undefined) { host = window.location.hostname } if (webPort === undefined) { webPort = window.location.port } + if (extWSURL !== undefined) { + host = window.location.hostname + webPort = window.location.port + scheme = window.location.protocol.slice(0,-1) + } let eventsServerClient = UI.projects.foundations.spaces.designSpace.workspace.eventsServerClients.get(layer.lanNetworkNode.id) @@ -190,7 +197,8 @@ function newPlottersManager() { host, webPort, eventsServerClient, - onProductStorageInitialized + onProductStorageInitialized, + scheme, ) function onProductStorageInitialized(err) { From 36f5895985ba2aa29392d89497b7c812fd4bf5c5 Mon Sep 17 00:00:00 2001 From: ph4z Date: Wed, 20 Oct 2021 21:54:44 +0000 Subject: [PATCH 2/2] Doc and tuto update for webSocketsExternalURL --- .../N/Network/Network-Node/network-node.json | 6 +++++- ...eralgos-010-tutorial-step-accessing-remotely.json | 12 +++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Projects/Foundations/Schemas/Docs-Nodes/N/Network/Network-Node/network-node.json b/Projects/Foundations/Schemas/Docs-Nodes/N/Network/Network-Node/network-node.json index 5b05971f4..533005932 100644 --- a/Projects/Foundations/Schemas/Docs-Nodes/N/Network/Network-Node/network-node.json +++ b/Projects/Foundations/Schemas/Docs-Nodes/N/Network/Network-Node/network-node.json @@ -61,6 +61,10 @@ { "style": "List", "text": "webSocketsPort is the port used by the system to communicate over the local area network, by default set at 18041." + }, + { + "style": "List", + "text": "webSocketsExternalURL is the URL used by the system to communicate over the wide area network, by default set undefined." } ] -} \ No newline at end of file +} diff --git a/Projects/Foundations/Schemas/Docs-Tutorials/W/Welcome/Welcome-to-Superalgos/welcome-to-superalgos-010-tutorial-step-accessing-remotely.json b/Projects/Foundations/Schemas/Docs-Tutorials/W/Welcome/Welcome-to-Superalgos/welcome-to-superalgos-010-tutorial-step-accessing-remotely.json index df536a218..a30278fac 100644 --- a/Projects/Foundations/Schemas/Docs-Tutorials/W/Welcome/Welcome-to-Superalgos/welcome-to-superalgos-010-tutorial-step-accessing-remotely.json +++ b/Projects/Foundations/Schemas/Docs-Tutorials/W/Welcome/Welcome-to-Superalgos/welcome-to-superalgos-010-tutorial-step-accessing-remotely.json @@ -138,7 +138,7 @@ }, { "style": "List", - "text": "Change the host parameter for the IP address of the machine running the backend.", + "text": "Change the host parameter for the IP address of the machine running the backend. If you use a reverse proxy you must manually add \"webSocketsExternalURL\": \"wss:\/\/mydomain.com:443\" config parameter.", "translations": [ { "language": "ID", @@ -160,13 +160,7 @@ }, { "language": "FR", - "text": "Changez le paramètre host pour l'adresse IP de la machine qui exécute le backend.", - "updated": 1623958474738, - "style": "List" - }, - { - "language": "FR", - "text": "Changez le paramètre host pour l'adresse IP de la machine qui exécute le backend.", + "text": "Changez le paramètre host pour l'adresse IP de la machine qui exécute le backend. Si vous utilisez un reverse proxy ajoutez manuellement \"webSocketsExternalURL\": \"wss:\/\/mydomain.com:443\" dans les paramètres de configuration ", "updated": 1623958474738, "style": "List" }, @@ -231,4 +225,4 @@ ] } ] -} \ No newline at end of file +}