OceanDataTools / openrvdas

An open source data acquisition system designed for use on research vessels and other scientific installations
http://openrvdas.org
Other
40 stars 21 forks source link

Allow ws access when remotely accessing openrvdas webUI via port forwarding #337

Open webbpinner opened 1 year ago

webbpinner commented 1 year ago

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";
davidpablocohn commented 1 year ago

This looks reasonable, but I can't figure out which file this is in - not django_gui/settings.py?

On Thu, Jul 20, 2023 at 2:46 PM Webb Pinner @.***> wrote:

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";

— Reply to this email directly, view it on GitHub https://github.com/OceanDataTools/openrvdas/issues/337, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFO7V3TE2EMV4V7OI3ELBF3XRESDVANCNFSM6AAAAAA2RL7N6Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

webbpinner commented 1 year ago

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

davidpablocohn commented 1 year ago

Got it. I'm not sure the text replacement you suggest would work, as even though it ends up being used in JS code, it's handed to the JS code via python, and first interpreted as a string in Python (in settings.py). And I don't think Python would know what to do with document.location.port.

On Thu, Jul 20, 2023 at 5:07 PM Webb Pinner @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/OceanDataTools/openrvdas/issues/337#issuecomment-1644100397, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFO7V3SJBCAFTO2ATKAOSLDXRFCUNANCNFSM6AAAAAA2RL7N6Q . You are receiving this because you commented.Message ID: @.***>

webbpinner commented 1 year ago

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 5 months ago

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 !!

davidpablocohn commented 5 months ago

Ah, I think you can get away with this because the display widget port is defined in JS code, but what Webb wants to change is specified in django_gui/settings.py[.dist]. And Python can't handle the js variable.

I think the way to get this done would be to tweak the (static) js to include a separate js config that's stashed somewhere canonical.

On Thu, Mar 28, 2024 at 10:06 AM LMG-ET @.***> wrote:

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 !!

— Reply to this email directly, view it on GitHub https://github.com/OceanDataTools/openrvdas/issues/337#issuecomment-2025708417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFO7V3UNYR6HAZHR3QZADBLY2REZRAVCNFSM6AAAAAA2RL7N6SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRVG4YDQNBRG4 . You are receiving this because you commented.Message ID: @.***>