On my console, I can pull up an IPFS test node with:
> iptb shell 0
> ipfs daemon
-- Initializing daemon...
-- Swarm listening on /ip4/127.0.0.1/tcp/55269
However, when I attempt to connect to it through node.js (on the same machine):
const IPFS = require('ipfs')
const node = new IPFS()
node.on('ready', () => {
node.swarm.connect('/ip4/127.0.0.1/tcp/55269', err => {
if (err) console.log(err)
})
})
I’m getting an error if (string.length === 0) return Buffer.allocUnsafe(0)
TypeError: Cannot read property 'length' of null
I get the same error if I try to connect to /ip4/127.0.0.1/tcp/55269/ipfs/[PEER_ID]
, but I see an error reported on my daemon console error reading rpc from <peer.ID PQoKLK>: stream reset comm.go:36
. Changing the address to the /p2p-circuit/… address gives me the error Error: No available transport to dial to
How do I go about establishing a tiny private network between my Node.js node and my dev Testbed (then eventually, other machines on my network) ? If I don’t want any outside connections, would I need something in the configuration to prevent it from connecting to the entire IPFS network?
Edit: I removed the .ipfs
and .jsipfs
repos, re-initialized, dropped the bootstrap nodes, fired up a console daemon, and I’ve now got the two nodes speaking to each other on a small network. I also had to add a small delay on the javascript node between connecting to the swarm and issuing my first command – I couldn’t find a callback that would wait until the connection was fully ready.