diff --git a/src/App.js b/src/App.js index 1f878d61b112989eec2ef618dcb39b21fdc74844..5c2a462f65c7f2f3234fa3c7777cc5dc18a28732 100644 --- a/src/App.js +++ b/src/App.js @@ -14,7 +14,6 @@ class App extends React.Component { componentDidMount() { this.mqttClientService = MqttClientService.instance; - //MqttClientService.instance.connect('ws://' + window.location.hostname + ':1884'); } render() { diff --git a/src/config.json.sample.oidc b/src/config.json.sample.oidc index 08c86f8fa37603e38fb21b31e4e288696dcf9a73..358b94a4a68198342b389e4d5263f341bc79deb2 100644 --- a/src/config.json.sample.oidc +++ b/src/config.json.sample.oidc @@ -12,6 +12,7 @@ "mqtt": { "url": "localhost", "port": "9000", + "websocket": "ws", "topics": { "base": "nrp_simulation", "errors": "runtime_error", diff --git a/src/services/mqtt-client-service.js b/src/services/mqtt-client-service.js index 40c94d8f9a0f52d902d3ca61788ba1a64d4a2648..2f5dcfd2942bee58086bab57614b244e1f1bb121 100644 --- a/src/services/mqtt-client-service.js +++ b/src/services/mqtt-client-service.js @@ -28,8 +28,9 @@ export default class MqttClientService extends EventEmitter { this.subTokensMap = new Map(); - // Since it's a singleton, shoud the url be defined here? - this.mqttBrokerUrl = 'ws://' + frontendConfig.mqtt.url + ':' + frontendConfig.mqtt.port; + // Since it's a- singleton, shoud the url be defined here? + const websocket_s = frontendConfig.mqtt.websocket ? frontendConfig.mqtt.websocket : 'ws'; + this.mqttBrokerUrl = websocket_s + '://' + frontendConfig.mqtt.url + ':' + frontendConfig.mqtt.port; this.connect(); }