Page 1 of 1

[Web Server] Cannot issue Free format commands

Posted: Mon Jan 09, 2017 11:53 pm
by tzieg
Hi,

I'm a OTGW newbee since a few days. otmonitor operates on a rpi3, connection to the gateway is via USB.
Reading the Log or displaying the Graph works gives identical results on both, the native OTGW interface and on the web-frontend.
Using the native OTGW interface, I can issue Free format commands such as PR=B in Section Miscellaneous which returns the build date of the firmware.
Via the web-frontend, this does not work, there is just no reaction.
Did I forget to set a specific option?

Thanks,
Thomas

Re: [Web Server] Cannot issue Free format commands

Posted: Tue Jan 10, 2017 10:32 pm
by hvxl
Which browser? It only works with a browser that supports websockets. Most notably that means it won't work with IE before 10. I tested with Firefox.

Re: [Web Server] Cannot issue Free format commands

Posted: Wed Jan 11, 2017 1:26 am
by tzieg
Ahh, yes, I read about browser incompatibilites but forgot to mention, I'm usually using Firefox or Chrome but not IE.

Just double checked:
- Firefox 50.1.0 under OSX El Capitan: no reaction for any command which writes to the server e.g. also switching between Monitor and Gateway mode
- Chrome 54.0.2840.100 under Debian-8: same behavior.

Connected question: should the Message Log in the browser automatically update? I need to actively reload the page via the browser.

Thanks,
Thomas

Re: [Web Server] Cannot issue Free format commands

Posted: Wed Jan 11, 2017 10:28 pm
by tzieg
Hi again,

I tried to use Chrome's Developer Tools to do a trace. Below are the error messages when navigating to Configure->Miscellaneous->Gateway.
I've attached the full contents of the Developer Tools window
Navigated to http://rpi3-wlan:8080/configure.html
Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://rpi3-wlan:8080/config.css".
Uncaught DOMException: Failed to construct 'WebSocket': The URL 'wsnullstatus.ws?var=cfg' is invalid.(…)
Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://rpi3-wlan:8080/config.css".
Uncaught DOMException: Failed to construct 'WebSocket': The URL 'wsnullstatus.ws?var=gwmode' is invalid.(…)
Uncaught TypeError: Cannot read property 'readyState' of undefined(…)
Seems, the WebSocket cannot be created. Any idea what goes wrong here?

Thanks,
Thomas

Re: [Web Server] Cannot issue Free format commands

Posted: Fri Jan 13, 2017 11:23 pm
by hvxl
The 'wsnullstatus.ws?var=cfg' is wrong. That should be 'ws://rpi3-wlan:8080/status.ws?var=cfg', but the regular expression that extracts the host name and port part doesn't handle the '-' in your host name correctly. It should work OK if you use the IP address, or create an alias FQDN that doesn't have a dash.

I'll fix the code.

Re: [Web Server] Cannot issue Free format commands

Posted: Sat Jan 14, 2017 1:40 pm
by tzieg
Hi hvxl,

Good catch!
Adding the the dash to the bracket expression of all occurrences of document.URL.match() solved the issue.

I've attached a simple patch.

Thanks,
Thomas

Re: [Web Server] Cannot issue Free format commands

Posted: Sat Jan 14, 2017 2:35 pm
by hvxl
Thanks for the patch. Without it I would probably only have changed one location.

Re: [Web Server] Cannot issue Free format commands

Posted: Wed Jan 01, 2020 1:31 pm
by tzieg
Happy New Year, Schelte,

I just realized, my patch from 2017 did not make it into the official sources. Was there anything wrong with the patch --or suboptimal?

Background:
  • My otgw ran now 3-years without problems with the otmonitor operating on a raspberry. The last days it crashed with a corrupted sdcard --and I did not have a backup :-(.
  • So I had to reproduce the setup using the latest executables from the otgw download page.
  • As my raspberry's hostname did not change --it's still rpi3-wlan.xxx.yyy, I ran into the same issues (dash in hostname leads to errors of the otmonitor web server) as in 2017.
  • I'm glad this forum still has my patch from that time ;-) so the fix was easy.
Seems everything is ok on my side --also a backup this time.

Decide on your own if it makes sense to use the patch --or a better solution.

Have a great year 2020,
Thomas

Re: [Web Server] Cannot issue Free format commands

Posted: Wed Jan 01, 2020 9:26 pm
by hvxl
There is absolutely nothing wrong at all with your patch. So it has been included in the code at gihub. But the "latest" executables from the otgw download page are still version 4.3 from April 2016. No major new features have been added that would justify the effort of creating a new version. And people who need one or more of the bug fixes can just use the latest github version.