From 6a9a1cdb3b9dcf33d567953bbee8103705f007b8 Mon Sep 17 00:00:00 2001 From: jack Date: Thu, 31 Jul 2025 10:48:22 +0200 Subject: [PATCH] Fix duplicate Nostr relay connections Add check to prevent creating multiple WebSocket connections to the same relay when connect() is called multiple times during app startup. --- bitchat/Nostr/NostrRelayManager.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bitchat/Nostr/NostrRelayManager.swift b/bitchat/Nostr/NostrRelayManager.swift index c3f6c8e8..41d98c23 100644 --- a/bitchat/Nostr/NostrRelayManager.swift +++ b/bitchat/Nostr/NostrRelayManager.swift @@ -168,6 +168,11 @@ class NostrRelayManager: ObservableObject { return } + // Skip if we already have a connection object + if connections[urlString] != nil { + return + } + // Attempting to connect to Nostr relay let session = URLSession(configuration: .default)