mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-25 15:18:29 +02:00
Fix nginx closing WebSocket connection after 60 seconds (#370)
* Test * Add keepalive * Revert "Add keepalive" This reverts commit 8b92198122daa0f67856d114dde26ac542d93114. * Update dashboard.py * Revert * Lint
This commit is contained in:
@@ -429,6 +429,8 @@ def run_logs(config, address):
|
||||
stopping = False
|
||||
retry_timer = []
|
||||
|
||||
has_connects = []
|
||||
|
||||
def try_connect(tries=0, is_disconnect=True):
|
||||
if stopping:
|
||||
return
|
||||
@@ -451,8 +453,13 @@ def run_logs(config, address):
|
||||
return
|
||||
|
||||
wait_time = min(2**tries, 300)
|
||||
_LOGGER.warning(u"Couldn't connect to API (%s). Trying to reconnect in %s seconds",
|
||||
error, wait_time)
|
||||
if not has_connects:
|
||||
_LOGGER.warning(u"Initial connection failed. The ESP might not be connected"
|
||||
u"to WiFi yet (%s). Re-Trying in %s seconds",
|
||||
error, wait_time)
|
||||
else:
|
||||
_LOGGER.warning(u"Couldn't connect to API (%s). Trying to reconnect in %s seconds",
|
||||
error, wait_time)
|
||||
timer = threading.Timer(wait_time, functools.partial(try_connect, tries + 1, is_disconnect))
|
||||
timer.start()
|
||||
retry_timer.append(timer)
|
||||
@@ -465,8 +472,6 @@ def run_logs(config, address):
|
||||
'TCP buffer - This is only cosmetic)')
|
||||
safe_print(time_ + text)
|
||||
|
||||
has_connects = []
|
||||
|
||||
def on_login():
|
||||
try:
|
||||
cli.subscribe_logs(on_log, dump_config=not has_connects)
|
||||
|
||||
Reference in New Issue
Block a user