From 34a11fe1bbf73848329d6e33ce2fc2409f8bcc57 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Thu, 19 Sep 2024 14:43:47 -0300 Subject: [PATCH] SigHelper: Handle all errors, lower time between retries --- src/invidious/helpers/sig_helper.cr | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/invidious/helpers/sig_helper.cr b/src/invidious/helpers/sig_helper.cr index 6705711d..347fd8bf 100644 --- a/src/invidious/helpers/sig_helper.cr +++ b/src/invidious/helpers/sig_helper.cr @@ -192,16 +192,18 @@ module Invidious::SigHelper loop do begin receive_data - rescue ex : IO::EOFError - LOGGER.info("Connection to helper died, trying to reconnect...") + # Handle all errors + rescue ex + LOGGER.info("Connection to helper died with '#{ex.message}' trying to reconnect...") # We close the socket because for some reason is not closed. @conn.close loop do begin @conn = Connection.new(@uri_or_path) - rescue - LOGGER.debug("Reconnection to helper unsuccessful, retrying.") - sleep 1 + LOGGER.info("Reconnected to SigHelper!") + rescue ex + LOGGER.debug("Reconnection to helper unsuccessful with error '#{ex.message}' retrying") + sleep 0.5 next end break if !@conn.closed? @@ -323,6 +325,11 @@ module Invidious::SigHelper return @socket.closed? end + def remote_address : Socket::IPAddress + + return @socket.remote_address + end + def close : Nil @socket.close if !@socket.closed? end