Skip to content

Commit cdbced9

Browse files
authored
fix: ensure relays on startup (#1926)
if the user has no apps then the relays are never connected to. This leads to the relays incorrectly shown as offline
1 parent 0e8a420 commit cdbced9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

service/start.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ func (svc *service) startNostr(ctx context.Context) error {
5959
}),
6060
))
6161

62+
// initially try connect to relays (if hub has no apps, pool won't connect to apps by default)
63+
for _, relayUrl := range svc.cfg.GetRelayUrls() {
64+
_, err := pool.EnsureRelay(relayUrl)
65+
if err != nil {
66+
logger.Logger.WithError(err).WithField("relay_url", relayUrl).Error("failed to initially connect to relay")
67+
}
68+
}
6269
go func() {
63-
// wait a few seconds for relays to connect
64-
time.Sleep(5 * time.Second)
6570
for {
6671
select {
6772
case <-ctx.Done():

0 commit comments

Comments
 (0)