Ipfs swarm disconnect: failure: conn not found

I’m trying to make a connection to a peer and then disconnect it, but I get:

disconnect QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy failure: conn not found

Steps:

  1. Connect to peer

ipfs swarm connect /p2p-circuit/ipfs/QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy

success!

ipfs swarm disconnect /p2p-circuit/ipfs/QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy

Get:
disconnect QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy failure: conn not found

Also I tried with variants of /ip4/IP/tcp/4001/ipfs/QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy but I got the same error

Any insight?

https://github.com/ipfs/go-ipfs/blob/master/core/commands/swarm.go#L423 which version do you use ?

root@fe0299e8b4c7:/uploader# ipfs --version
ipfs version 0.4.14
root@fe0299e8b4c7:/uploader# ipfs swarm connect /p2p-circuiyWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy
connect QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy success
root@fe0299e8b4c7:/uploader# ipfs swarm disconnect /p2p-cirdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy
disconnect QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy failure: conn not found

That doesn’t help.

If I run

ipfs swarm addrs I can see the peerId like

QmUZ7t5hVXMdt2yWAPkDVBuSPuGc8uNNzSzNWDoZ1i5eLy (4)
ip4/....
ip4/....
ip4/....
ip4/....

I don’t know why it works like this, but if you grab the full peer ID connection for the connection from ipfs swarm peers then use that with ipfs swarm disconnect it works as expected.

For example:

$ ipfs swarm connect /p2p-circuit/ipfs/QmSF2YVkh7PsWUG15QXbr6QeWaeVdaEVL3FjC8mFN9vwkZ
connect QmSF2YVkh7PsWUG15QXbr6QeWaeVdaEVL3FjC8mFN9vwkZ success
$ ipfs swarm peers | grep wkZ
/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVDKNAd/p2p-circuit/ipfs/QmSF2ZVkh7PsWUG15QXbr6QeWaeVdaEVL3FjC8mFN9vwkZ
$ ipfs swarm disconnect /ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVDKNAd/p2p-circuit/ipfs/QmSF2YVkh7PsWUG15QXbr6QeWaeVdaEVL3FjC8mFN9vwkZ
disconnect QmSF2YVkh7PsWUG15QXbr6QeWaeVdaEVL3FjC8mFN9vwkZ success

wow, it seems it creates another IP for the peer connection.

Thanks @leerspace

One single line command could be

ipfs swarm disconnect $(ipfs swarm peers | grep *peerID*)

In case anyone comes across this thread and is curious like I was, the connection to the p2p-circuit address happens through a relay. That’s where the stuff before the address that was specified in the ipfs swarm connect command comes from.

This is documented in more detail here:

1 Like