Merge pull request #2174 from ph4z/develop

Contribution: Accept webSocketsExternalURL parameter on network node config
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-10-20 03:19:58 -04:00
commit 24a80a903a
1 file changed
+7 -2
+7 -2
View File
@@ -218,11 +218,12 @@ function newEventsServerClient(lanNetworkNode) {
try {
let host
let port
/* At this point the node does not have the payload property yet, that is why we have to do this manually */
let extwsurl
try {
let config = JSON.parse(lanNetworkNode.config)
host = config.host
port = config.webSocketsPort
extwsurl = config.webSocketsExternalURL
/* Check if we really have to stablish the connection. */
if (config.autoConnect === false) { return }
@@ -268,8 +269,12 @@ function newEventsServerClient(lanNetworkNode) {
return
}
const WEB_SOCKETS_URL = 'ws://' + host + ':' + port + ''
let wsurl = 'ws://' + host + ':' + port + ''
if (extwsurl !== undefined) {
wsurl = extwsurl
}
const WEB_SOCKETS_URL = wsurl
WEB_SOCKETS_CONNECTION = new WebSocket(WEB_SOCKETS_URL)
WEB_SOCKETS_CONNECTION.onerror = error => {
console.log('WebSocket error:' + JSON.stringify(error))