OceanDataTools/openrvdas

Allow ws access when remotely accessing openrvdas webUI via port forwarding

webbpinner opened this issue · 6 comments

Several vessels provide remote access to the OpenRVDAS via ssh-based port forwarding. This works for the static portions of the OpenRVDAS webUI but because the port used for the ws connection is explicitly defined to a port number within the settings.py file the ws socket traffic is not accessible when accessing via ssh port-forwarding.

Running on the assumption that the WS port is the same as the port used by nginx during install would it be possible to define the ws port as the same port specified in the URL.

TL;DR
Can the default vault of WEBSOCKET_SERVER be changed from:

var WEBSOCKET_SERVER = "ws://:80/cds-ws";

To:

var WEBSOCKET_SERVER = (document.location.protocol === 'https:' ? 'wss' : 'ws' ) + '//:' + document.location.port + "/cds-ws";

It's in:
https://github.com/OceanDataTools/openrvdas/blob/master/django_gui/templates/django_gui/index.html
but that file just refers back to what's set in settings.py... or at least that's the way I'm interpreting the code

I was curious about that. My initial thought was that the string would be not be interpreted until it was in the browser which I assumed would be fine as just a JS string passed to the template via the Django code. I might be wrong in that assumption.

LMG-ET commented

We've solved that one.
We tweaked ${OPENRVDASROOT}/display/js/widgets/settings.js

var WEBSOCKET_PORT = window.location.port || 443;

That file may or may not have been generated by something further upstream (I'd have to run through the installation script and whatnot to give you a definitive answer), but ....

Standard disclaimer: It works for me !!