BASIC UI “Offline: Waiting for Connection to become available”, yet again

Yesterday i occasionally run into this problem. Figured it out this time.
I’ve never had it before and that was a surprise. Plus, i was working on a different project, and reconfigured my sitemap slightly to add controls for my new Thing under testing; so it felt like the change has caused it. Bottom line: it took some of my nerves, but i figured it out.

It turned out to be a coincidence. Recently flash drive in my PC died, so i reinstalled my Windows and whole software from scratch. Perhaps this changed some settings in Firefox. In order to go to my BasicUI, i typed a 192.168.X.X local address in a URL bar. And went there. And the browser chose to use http://, not https://. But BasicUI code internally insists on https:// to call a subscription URL. And here comes the problem: my browser blocks it because of CORS policy. I found this out in developer’s console.

To verify this, i went to the same IP using https://. I am using a self-signed certificate, so that was fine. After a warning i got a fully working BasicUI, no problem anymore.

Yesterday i failed to realize that could be the culprit; and simply ran with this error for some time. Because controls actually worked. And that eventually somehow led me to another error: SSE subscription failed. Which is also well-known, a suggested cure is to delete addons.conf (strange but okay)

So, perhaps i found two bugs:

  1. Subscription URL is fully-specified including https:// protocol, which breaks CORS if the user uses http:// to get to the control panel. Maybe plain http is out of fashion, still you can get it simply by typing an IP. The problem is aggravated further by the fact that Firefox loves to hide protocol specifier from the URL bar, so you don’t see it. This is confusing. Shouldn’t openhab use just ‘/’ in this URL ? Or, if http if so much deprecated, simply redirect to https, so that this situation can never happen ?

  2. Running for some time with “Offline” error eventually brings you into some compatibility mode, which may leak subscription descriptors somehow and trigger “SSE subscription failed”. It appeared not only on this PC, but on two my wall panels also; so that was quite a bad experience.

Just for info: my OH version is openHAB 3.2.0 stable. Yes, i know it’s a bid old.

If you use port 8443, all calls and URLs that BasicUI uses will be HTTPS. If you use port 8080, all calls and URLs that BasicUI uses will be HTTP.

However, if you have a webview on the page, it’s up to us to specify HTTP or HTTPS in that URL.

If you want to you can set up a reverse proxy to redirect port 8080 to 8443.

Over all it is very unclear what you have done to cause this error without the actual URLs.

Also, a lot of changes have occurred on the SSE between 3.2 until now so if there is a problem here it needs to be tested on latest to see if it’s still a problem.

Very easy. I have set up nginx with authentication as suggested; it sits on default ports and forwards me.
So, i typed an IP without port, and it apparently forwarded me, so i see the page, but port number is completely alien.
This is a hypothesis, i will test it later.

Something in the back of my head actually tickled me that “it should not respond on default port”, but… The setup works too well :slight_smile: , so i don’t bother and forget details over time.

Yes, confirmed. I should probably tighten my nginx config to only respond on https. I didn’t take it as important because anyways it only sits inside my LAN, and only https port is forwarded from outside on my router.

I think it deserves being somehow mentioned in docs; because this could be a common pitfall. Too easy to get into.