@@ -620,10 +620,22 @@ func (s *StackManager) peerIPFSNodes() error {
620620 continue
621621 }
622622 addr := fmt .Sprintf ("/dns4/ipfs_%s/tcp/4001/p2p/%s" , other .ID , peerIDs [other .ID ])
623- url := fmt .Sprintf ("http://127.0.0.1:%d/api/v0/swarm/peering/add?arg=%s" , member .ExposedIPFSApiPort , addr )
624- if err := core .RequestWithRetry (s .ctx , http .MethodPost , url , nil , nil ); err != nil {
623+
624+ // swarm/peering/add only registers the peer with Kubo's background
625+ // reconnect service - it returns success even when the peer is
626+ // unreachable, so it does not confirm a connection was made.
627+ peeringURL := fmt .Sprintf ("http://127.0.0.1:%d/api/v0/swarm/peering/add?arg=%s" , member .ExposedIPFSApiPort , addr )
628+ if err := core .RequestWithRetry (s .ctx , http .MethodPost , peeringURL , nil , nil ); err != nil {
625629 return fmt .Errorf ("failed to peer IPFS node %s with %s: %w" , member .ID , other .ID , err )
626630 }
631+
632+ // swarm/connect dials synchronously and errors if the connection
633+ // fails, so retrying it confirms the nodes are actually connected
634+ // rather than just registered to reconnect in the background.
635+ connectURL := fmt .Sprintf ("http://127.0.0.1:%d/api/v0/swarm/connect?arg=%s" , member .ExposedIPFSApiPort , addr )
636+ if err := core .RequestWithRetry (s .ctx , http .MethodPost , connectURL , nil , nil ); err != nil {
637+ return fmt .Errorf ("failed to connect IPFS node %s to %s: %w" , member .ID , other .ID , err )
638+ }
627639 }
628640 }
629641 return nil
0 commit comments