HomeAssistant and Websockets

1. The problem I’m having:

Homeassistant resolves perfectly in web browser, but does not resolve on the companion app. I receive a “Starscream.HTTPUpgradeError 0”. From searching this appears to be an issue due to websockets, but from what I saw, caddy should not need special config for websockets (is this correct?)

2. Error messages and/or full log output:

The operation couldn’t be completed. (Starscream.HTTPUpgradeError error 0.)

Error Code:
Starscream.HTTPUpgradeError 0

3. Caddy version:

v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=

4. How I installed and ran Caddy:

Installed as service via tailscale videos and this script
from: video-caddy-custom-domains/caddy at main · tailscale-dev/video-caddy-custom-domains · GitHub

#!/bin/bash
# downloads the caddy binary with the cloudflare plugin enabled
# must be run as root

caddy_path="/usr/local/bin/caddy"

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

if [ -f "$caddy_path" ]; then
    echo "$caddy_path exists..."
    echo "Nothing to do. Exiting."
    exit 1
else
    curl "https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddy-dns%2Fcloudflare" -o $caddy_path
    chmod +x $caddy_path
fi

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/local/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/local/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateDevices=yes
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

a. System environment:

ubuntu server running in vm on proxmox host

d. My complete Caddy config:

(cloudflare) {
        tls {
                dns cloudflare
        }
}

# adguard
adguard.two.friedbananapies.org {
        reverse_proxy http://192.168.68.2
        import cloudflare
}

# ha
ha.two.friedbananapies.org {
        reverse_proxy http://192.168.68.195:8123
        import cloudflare
}


I hope that’s not your real Cloudflare API key. If it is, you need to revoke it immediately and make a new one, otherwise people will be able to take control of your site via updating your DNS records.

Correct, Caddy’s reverse_proxy has websocket support out of the box.

What about your Caddy logs?

2 Likes

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