I’m trying to setup a gateway that exposes my node to a js-ipfs browser based, so that I can reliably send pub-sub messages. I find that unless I connect to the same peers the pubsub messages get lost. I’m trying to use docker and caddy. My question is basically, how do I configure the websocket connection on the go-ipfs side, and what is the initial swarm that I’ll need on the browser js-ipfs side?
Here’s the current setup. Test machine name is ssb.willschenk.com
:
docker create network identity
start_ipfs.sh:
IPFSDATA=${PWD}/ipfs_data
IPFSEXPORT=${PWD}/ipfs_export
docker run --name ipfs \
-d --restart unless-stopped \
-p 4001:4001 \
-p 127.0.0.1:8080:8080 \
-p 127.0.0.1:5001:5001 \
--network identity \
-v ${IPFSDATA}:/data/ipfs \
-v ${IPFSSTAGING}:/export \
-m 900m\
ipfs/go-ipfs \
daemon --writable --enable-pubsub-experiment
start_caddy.sh
CADDYFILE=${PWD}/Caddyfile
docker run --name caddy \
-d --restart unless-stopped \
-p 80:80 -p 443:443 \
--network identity \
-v ${PWD}/html:/html \
-v ${CADDYFILE}:/etc/Caddyfile \
-v ${ACCESSLOG}:/src/access.log \
-v caddy_keys:/root/.caddy \
-e ACME_AGREE=true \
-e HOSTNAME=${HOSTNAME} \
abiosoft/caddy
Caddyfile:
{$HOSTNAME}
root /html
gzip
cors
cache
log
errors error.log
proxy /ipfs/ http://ipfs:8080/
proxy /ws http://ipfs:8081 {
websocket
}
And then I’ve set inside of the config
file:
"Addresses": {
"API": "/ip4/0.0.0.0/tcp/5001",
"Announce": [],
"Gateway": "/ip4/0.0.0.0/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip4/0.0.0.0/tcp/8081/ws",
"/ip6/::/tcp/4001"
]
},
And my node test code:
const IPFS = require('ipfs')
const node = new IPFS({
config: {
Addresses: {
Swarm: [
'/dns4/ssb.willschenk.com/tcp/443/wss/p2p-websocket-star'
]
}
}
})
console.log( "Connecting" )
node.on('ready', async () => {
const version = await node.id()
console.log( version )
console.log( "Peers" )
const peers = await node.swarm.peers()
console.log(peers)
})
So my questions are:
- What am I doing wrong?
- What is the right path to proxy from Caddy to the ipfs websocket server? I’m using
/ws
on my public facing proxy server to proxy to the 8081 port? - What should my initial swam address be in the node side? I’m using
'/dns4/ssb.willschenk.com/tcp/443/wss/p2p-websocket-star'
but it doesn’t show any peers or error messages? - How do I debug js-ipfs better? Why is it silently starting?
- Is there something special I need to do to enable
p2p-websocket-star
on the go-ipfs side?
Been banging my head against this but there are too many things I don’t understand to move forward… Thanks in advance.