My goal is to be able to see the discover, incoming connection, and accepting connection in the parachain network, which I'm guessing should update the Idle 0 Peers to 1 Peer. I'm still currently trying to fix this issue. If theres anything else that you need from me, please let me know!
This is my parachain terminal command. './target/release/polkadot-parachain --chain customSpecRaw.json --tmp --rpc-cors all --port 4003 --unsafe-rpc-external --rpc-methods=unsafe --collator --detailed-log-output --reserved-only --sync=fast-unsafe -l peerset=trace'
This is my express block of codes that I'm creating the node through js-libp2p.
const options = {
peerId: peerId,
addresses: {
listen: ['/ip4/192.168.1.203/tcp/9944/ws']
},
transports: [
tcp(),
webSockets(),
circuitRelayTransport({
discoverRelays: 2,
})
],
connectionEncryption: [noise()],
streamMuxers: [yamux(), mplex()],
dht: kadDHT(),
peerDiscovery: [
mdns(),
pubsubPeerDiscovery(),
bootstrap({
list: bootstrapNodes
}),
],
services: {
identify: identify(),
ping: ping({
protocolPrefix: 'ipfs',
}),
dht: kadDHT({
kBucketSize: 20,
clientMode: false,
broadcast: true,
}),
relay: circuitRelayServer(),
pubsub: gossipsub({
allowPublishToZeroPeers: true,
emitSelf: true,
floodPublish: false,
gossipIncoming: true,
doPX: false,
directPeers: gossipPeers,
allowedTopics: 'Login'
})
},
config: {
dht: {
kBucketSize: 20,
enabled: true,
randomWalk: {
enabled: true,
interval: 300e3,
timeout: 10e3
}
},
pubsub: {
enabled: true,
emitSelf: false,
},
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
},
autoNAT: {
enabled: true,
},
},
connectionManager: {
autoDial: true,
maxConnections: 50,
minConnections: 10,
},
}
const node = await createLibp2p(options);
node.addEventListener('peer:discovery', async (event) => {
const peerInfo = event.detail;
console.log("New peer discovered", peerInfo.id.toString());
const rpcUrl = 'http://127.0.0.1:9944';
const body = JSON.stringify({
jsonrpc: '2.0',
method: 'system_addReservedPeer',
params: [
`/ip4/192.168.1.203/tcp/4003/ws/p2p/${peerId}`
],
id: 2
});
const response = await fetch(rpcUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body
});
})
node.addEventListener('peer:connect', async (event) => { console.log('peer connect', event.detail) })
await node.start(); }