From 49f206eab305439a3105a43d7f0b607a14eea03d Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:54:38 +0200 Subject: [PATCH] exponential delay for reconnect --- nostr/relay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nostr/relay.py b/nostr/relay.py index 2649a4d..7fb4baa 100644 --- a/nostr/relay.py +++ b/nostr/relay.py @@ -35,7 +35,7 @@ class Relay: self.reconnect: bool = True self.shutdown: bool = False self.error_counter: int = 0 - self.error_threshold: int = 0 + self.error_threshold: int = 100 self.num_received_events: int = 0 self.num_sent_events: int = 0 self.num_subscriptions: int = 0 @@ -76,7 +76,7 @@ class Relay: pass self.connected = False if self.reconnect: - time.sleep(1) + time.sleep(self.error_counter**2) self.connect(self.ssl_options, self.proxy) @property