From 59cc1f0d184edf45a2b13fd1070e10ddd7f106b5 Mon Sep 17 00:00:00 2001 From: Brian Dunlay Date: Sat, 11 Jan 2020 02:41:21 -0800 Subject: [PATCH] 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]: https://github.com/home-assistant/home-assistant/blob/9c551ae85d68a8c82c706d6e2cf044cfd5533054/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 --- source/_docs/ecosystem/haproxy.markdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/_docs/ecosystem/haproxy.markdown b/source/_docs/ecosystem/haproxy.markdown index b9a09fed76d..85c99300b07 100644 --- a/source/_docs/ecosystem/haproxy.markdown +++ b/source/_docs/ecosystem/haproxy.markdown @@ -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 :8123