Error with websockets

Hi there!

I am running a instance of HA in a python virtual env, in a ubuntu server 17.

My HA version is 0.65.5

I have configured DuckDNS, lets encrypt, and dnsmasq for emulating NAT loopback, as my router doesn’t support it.

When I access from my internal network, with https://[INTERNAL_IP]:8123 everything works well
When I access from outside with https://[NAME].duckdns.org:8123 everything works well to

The problem is accessing from my internal network, with the duckdns url. It enters to the connecting page in chrome, but this call wss:///[NAME].duckdns.org:8123/api/websocket?latest doesn’t resolve. I have access to the server, because the https requests are working fine, but the websocket don’t, and I can’t find the cause.

I don’t have seen some topics about this, but it’s always related to proxys, and I am not using it.
https://www.reddit.com/r/homeassistant/comments/6rgf04/frontend_unable_to_connect/

I wonder if someone can guide me to the solution. Or at least, what kind of server is using HA by default, so I can dig into the configuration, and check if I can make a fix like in the nginx posts

Thanks!

Im having this problem also.
Did you find a solution?

1 Like

Hi have the same issue,

HA version: 0.81.6 (Python 3.6.7)
OS: debian jessie (Raspberry Pi) Linux raspberrypi 4.14.78-v7+ #1156 SMP Tue Oct 23 14:34:39 BST 2018 armv7l GNU/Linux

When I access directly with :8123 I don’t have any issue.

But when I access through HTTPS (through freedns+Apache ProxyPass+LetsEncrypt certs) I have an error on wss: requests

(from chrome extension console)
"core-fe8f251c.js:1 WebSocket connection to ‘wss://myDomain/api/websocket’ failed: Error during WebSocket handshake: Unexpected response code: 500 "

I can’t see any details on HA logs.

Also I tried to configure through FreeNom + Cloudfare + Apache 80 (as described in https://domoticaencasa.es/foro/viewtopic.php?f=10&t=6 ) but I have the same error!

SOLVED: I’ve reviewed Apache2 logs
"AH01144: No protocol handler was valid for the URL /api/websocket . If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. "

Looking for stackoverflow, I’ve enable a lot of modules again:

sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod proxy_fcgi

I’ve restarted … and voila!

I had similar issue’s where I run Home Assistant in a docker on Synology. The login pages were working, but after login the redirect to Lovelace was not working. I was banging my head against the wall, and even this thread couldn’t help me.
But for others who run into the same issue; When you are runnin Home Assistant in a Syno docker, and use Synology Reverse Proxy, you need to perform extra steps to enable websocket support for synology Reverse proxy. Matthias Lohr did a great writeup explaining what to do:

Hope it helpes someone

1 Like

I solved a similar issue, I had multiple problems I needed to fix. I’m reporting here in case anyone else was searching (like me) for a solution!

  • I was using wss as the protocol in the RewriteRule rather than ws, wss is only if you’re proxying to a server with SSL.
  • I needed to install proxy_wstunnel (thank you @jorcat !), despite not having any errors in my apache logs.
1 Like

I don’t know, That was year and a half ago, and with a router change to have access to NAT loopback and proper DNS configuration, I don’t have that problem anymore

This helped me today. Thank you!

One last security setting needed changed. I followed the instructions for reverse proxy and was able to log into my home assistant system remotely. The issue was that I only got an “Unable to Connect” screen with retry as the only option instead of my HA dashboard. Retry did not work of course.

What it came down to was my setting for “TLS / SSL Profile Level” under Control Panel > Connectivity > Security > Advanced. I previously chose “Modern” but had to drop it to the recommended “Intermediate” option:

I did attempt to use the Custom Settings option and override only the subdomain for my HA instance. That did not seem to work. Maybe I could try to do it for the main domain and the subdomain but at that point I am more or less back to choosing “Intermediate” for everything I use remotely.

how to fix it if using nginx?