From ea9fc18c151cd7fd500c8367be6f7952619cbb82 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 18 Apr 2023 17:50:41 +0200 Subject: [PATCH] reconnect on on_close --- nostr/relay.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nostr/relay.py b/nostr/relay.py index 7595d9a..2649a4d 100644 --- a/nostr/relay.py +++ b/nostr/relay.py @@ -129,6 +129,10 @@ class Relay: def _on_close(self, class_obj, status_code, message): self.connected = False + if self.error_threshold and self.error_counter > self.error_threshold: + pass + else: + self.check_reconnect() pass def _on_message(self, class_obj, message: str): @@ -139,10 +143,6 @@ class Relay: def _on_error(self, class_obj, error): self.connected = False self.error_counter += 1 - if self.error_threshold and self.error_counter > self.error_threshold: - pass - else: - self.check_reconnect() def _on_ping(self, class_obj, message): return