SigHelper: Handle all errors, lower time between retries
All checks were successful
Invidious CI / build (push) Successful in 9m1s

This commit is contained in:
Fijxu 2024-09-19 14:43:47 -03:00
parent 2db9396dea
commit 34a11fe1bb
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4

View file

@ -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