[SOLVED] REST API SSE streams not working (WAS: Items on Main UI not showing states on cards)

UPDATE:

I have renamed this thread as the issue is to do with the requests for an SSE stream from REST API are not going through (see my post here).

END UPDATE

Relevant Info (I think)

I am not sure what information about my OpenHAB setup and my PC to include, or how to format it, so please tell me if you need anything more.

Server is an Rpi 3B connected to Internet router using Ethernet.

My laptop:

  • Windows 10 Dell laptop

Working clients:

  • My father’s Windows 10 Dell laptop
  • My Android 10 Samsung phone
  • My Pi 3B+ I use as a desktop
  • A VirtualBox Windows 10 emulator

I have looked at the only other threads on here that are about this, and have made a bit of progress using the info I have found.
The threads:

I have the same problem as the first and second threads.
I included the third thread because I think the following is relevant:

It turns out that my antivirus program (avira Pro) blockes some mime types, what are essential for the widgets => text/event-stream

After i add the Mime Type to the exception list everything is working on my PC too…

I find a website where the problem is descripted.
Link
It seems that the source code of OH3 is not 100% compatible with W3C Standards

Background

I have dabbled with OpenHAB 2, and when I saw OpenHAB 3 was stable, I set up an instance using OpenHABian.

I started setting up stuff using my laptop. After fiddling around for a while, I got the Model and some Things and Items set up. However I did things, I absolutely could not get the Main UI to display Item states on cards. I could see their states in the Item config menu and HABPanel, but not on cards.

Thinking I had made a configuration error, I deleted my Things and Items, and set up an HTTP URL Thing called OpenHABForumAbout and an Item linked to called OpenHABForumAbout_TopicCount, as done in the OpenHAB Virtual Meet Up.

I opened it the Main UI on my phone, and voila, everything was working fine. I decided to check if it was a Windows thing, and opened it on my father’s laptop. Also working.

Further Investigation

I thought it may be because of stuff I had installed on my laptop, so I set up a Windows 10 emulator in VirtualBox (I will refer to this as ‘the emulator’). I loaded up the Main UI in the emulator, and it worked fine.

It is definitely something to do with my laptop.
I tried with multiple browsers on my laptop, and none worked.
On my laptop:

  • Chrome (standard, Beta, Dev, and Canary)
  • Firefox
  • Edge

I tried on my phone, and every one I tried worked:

  • Chrome (standard and Canary)
  • Samsung Internet

In the emulator:

  • Chrome
  • Edge

Chromium, the only browser on my desktop Pi, also worked.
Chrome on my father’s laptop worked (I did not try other browsers).

I investigated further:
The following are not working on my laptop:

  • Accessing items and groups using expressions (e.g. =items.OpenHABForumAbout_TopicCount)
  • Showing item states on cards
  • Showing item states on HABot Cards (EDIT: on the Main UI chatbox. Normal HABot works fine)
  • Event Streaming

It may be to do with the above functionality using MIME type text/event-stream somewhere, and it getting blocked. Other people using or writing other software get the identical errors in Chrome and Firefox due to this being blocked by AV software.

I have tried with all (as far as I know…) my antivirus and ad-blocking software disabled, to no avail.

I have tried debugging the JS in Chrome to see when things go wrong, and found out a little: HABot (on the Main UI) returns the correct item, and the correct item states are being got from the REST API, but it seems that the cards use something else, which is not working.

My current conclusions

What it is not:

  • It is not a browser issue: I have tried the same browser on multiple platforms.
  • Nor is it a browser-extension issue: My extensions synced on my emulator’s Chrome when I signed in.
  • It is not a Windows-wide thing: It works on a real Windows 10 laptop and an emulator.

My only semi-definite conclusion is that it is something to do with my network configuration or AV software.

Side Note: HTTPS is also not working on my laptop (when trying in Insomnia I get Error: SSL peer certificate or SSH remote key was not OK; disabling SSL Certificate Validation makes it work), but fine on everything else. This may be related. Should I start another topic?

Sorry if this is all a bit long ;).

I will not be available on Sunday, and not much on Saturday, so I may not reply until Monday.

Just to make it clear: I am not saying it is specifically a bug in OpenHAB. I am pretty sure it is my laptop setup. I am more hoping that someone will be able to explain a bit about how the parts that are not working are different to the parts that are working, so I can try and fix whatever is wrong on my side.

Hi Darryl,

I had the same problem. (I created the threat " no data visible in widgets" )

Just disabling the anti virus scanner isn’t enough

In my setup it was the web secury what is a seperate subcomponent of the virus scanner.

When you disable the VirusScan you just disable the Anti Virus Part not Websecurity or Firewall.

You have to disable them seperatly

This component is automatically used in all browser you install on your laptop.

What Anti-virus Scanner do you have?

I did the same…
Setup a virtual sandbox and tried it, use mobile phone,…

At least I activated debug logging of the Anti virus.

There I found the topic with web security and blocked mime type.

So please look in the onfiguration of the Antivrus Program if there is a component like Web Security.

Put an exception in the config for the ip or fqdn of the openhab system

I am sure it is the same problem.
In all other threats you mentioned it was also the web security config

Greetings Thomas

Thanks for the extra info.

I have/had Trend Micro Maximum Security and Windows Defender SmartScreen. I previously also had the McAfee Chrome extension.

I have found a lot of other, possibly related, things that I can disable. I will try again on Monday.
Since Trend Micro is not working properly, I was going to uninstall and reinstall it anyway. I will see what happens in that regard.

Maybe you can try the following

https://helpcenter.trendmicro.com/en-us/resources/titanium_product_guide/

Page96: define exceptions for WebScan:

Enter the url of openhab like you enter in browser to open the site for example http://openhabdevice.fritz.box (without port)

This is a strange issue. I started the “Not getting past first base” thread earlier.

OH3 is running on an RPi2B connected to my router via cable. I included my OH3 installation URL: openhab3.local in the “no webfilter” setting in my AV which is Sophos. No success.

Then suddenly one day later everything started to work in Chrome on my Mac. I cannot say why! Maybe there has been an update of Chrome meanwhile. I am running Chrome Version 87.0.4280.88 (Official Build) (x86_64) on Mac OS 10.15.7 (Catalina). Safari also works!

Since this I have removed the setting from the Sophos webfilter and things still work. I have not been able to reproduce the error!

It was Trend Micro!

I uninstalled it now, and the dashboard works! (EDIT: Must have just been that I never tried opening the dashboard soon after booting.)
I will reinstall it and follow the guide @eloka080677 mentioned to stop it blocking the dashboard, if it still does (it wasn’t working properly, so it may have been a “glitch”).

Annnnnnd, it’s not working again (Without me doing anything. I reloaded the webpage and it broke.).

Will investigate further.

EDIT 1:
Working again!
I restarted and opened Chrome as soon as I could (in case some AV service starts soon after boot). Bam! It’s working.

EDIT 2:
Not working, again. As soon as I run the Trend Micro installer (the same as when I first posted this reply)…

EDIT 3:
Nope, must be coincidence. It was about 3 minutes after boot. I will see if it’s repeatable…

EDIT 4:
I installed and setup Trend Micro (did not change any whitelists or anything).
Dashboard worked for about 4 minutes after boot.

EDIT 5:
Rebooted.
Dashboard stopped working momentarily and Trend popped up a notification saying that real-time scanning and web-filtering are enabled, then worked again.
I stopped working about 4 minutes after boot again, at about the same time that Windows Security pops up a notification that its firewall is disabled. Maybe Windows Security only starts about 4 minutes after boot…

EDIT 6:
Rebooted again.
3 minutes after boot, it started randomly either working or not working.
30 seconds later, the notification about the firewall being disabled appears, and the dashboard doesn’t work again…

I guess it must be Windows Security, but then why does it work on my emulator? :thinking:

I tried leaving Trend Micro installed but disabling most stuff in it, after seeing this:

It seems that the SSE connection is treated as a download and thus not released to the browser until the connection is closed and the stream received to scan.

No luck there.

I installed Fiddler Everywhere 2 days ago.
It creates a proxy for monitoring network traffic, which, for some reason, fixes the problem as long as it’s monitoring traffic (i.e. when the proxy is running).

After looking around in the Chrome developer tools, I found some out a bit more:
Before requesting /rest/events, (the SSE stream for getting events), it tries to get a “connection ID” from /rest/events/states (also an SSE stream…), but the request does not complete on my machine. Navigating to it in the Chrome address bar just loads for ever. In the Network tab of the developer tools, it shows the request to /rest/events/states as “stalled”. On other machines, /rest/events/states returns this:

event: ready
id: 0
data: 6c164496-eae3-47c8-9687-380a4cfffe1b

with data being the requested connection ID (it is different every time, of course).

Because this request does not complete, the dashboard cannot do anything else. It does not even request /rest/events because of that missing ID. So /rest/events is not the only problem.

I looked at the request info in Chrome again.
The request to /rest/events/states stays stalled under Connection Start on the Timing tab of the its info.
This means that the request is not even being sent.

This is what it should look like:

I had the same issue.

On my laptop with Win 10 and Sophos Home Anti Virus, no item states where displayed. Not in Firefox and not in MS Edge (chromium).

I added an exception to the Sophos webfilter to exclude the IP of my openHAB. Now it works without any Problems.

Two more threads I found

This one is (AFAIK) the same problem:

This was linked in that thread:

SOLVED

Windows was slowly disintegrating (this was just one minor thing…), so I performed a Windows Reset.

So far, the one of the errors I was getting (Intel Optane Memory Pinning Exception) is gone, and the OpenHAB Main UI works.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.