Add tunnel timeout to support websocket connections (#11708)

HomeAssistant uses a 55 second interval[1] to send heartbeats to
the Lovelace UI over WebSockets. If the tunnel timeout[2] is not
set, the WebSocket connection from the browser to the server is
reset every 50 seconds. When the connection resets, it reconnects
automatically, and causes the page to reload. Any unsaved data in
forms is lost.

This commit adds a sane default of 60 seconds to the HAProxy
configuration for tunneled connections, so that the frontend
WebSocket connection doesn't time out every 50 seconds.

[1]: 9c551ae85d/homeassistant/components/websocket_api/http.py (L111)
[2]: https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4-timeout%20tunnel

Related: home-assistant/home-assistant-js-websocket#108
This commit is contained in:
Brian Dunlay 2020-01-11 02:41:21 -08:00 committed by Franck Nijhof
parent ce07145f14
commit 59cc1f0d18

View File

@ -57,7 +57,8 @@ defaults
timeout connect 5000
timeout client 50000
timeout server 50000
timeout http-request 5s #protection from Slowloris attacks
timeout tunnel 60000 # long enough for websocket pings every 55 seconds
timeout http-request 5s # protection from Slowloris attacks
frontend www-http
bind *:80
@ -68,7 +69,7 @@ frontend www-https
bind *:443 ssl crt /etc/haproxy/certs/MYCERT.pem
acl hass-acl hdr(host) -i SUBDOMAIN.DOMAIN.COM
use_backend hass-backend if hass-acl
backend hass-backend
server hass <Home Assistant Server IP>:8123