Closed litzenberger closed 5 years ago
@alanshaw Are there examples of how js-ipfs uses the different above transports? It it enough to just setup a connection like above or do I also have to include the following in the libp2p config? `` modules: { transport: [ TCP, WebSockets ]
@litzenberger this relates to libp2p configuration.
You should be able to configure the libp2p module using the libp2p.modules
property of the IPFS constructor options.
// tcp, mplex
{
modules: {
transport: [TCP],
streamMuxer: [Multiplex],
connEncryption: []
}
}
// websocket, mplex
{
modules: {
transport: [WS],
streamMuxer: [Multiplex],
connEncryption: []
}
}
// tcp, mplex, secio
{
modules: {
transport: [TCP],
streamMuxer: [Multiplex],
connEncryption: [SECIO]
}
}
// websocket, mplex, secio
{
modules: {
transport: [WS],
streamMuxer: [Multiplex],
connEncryption: [SECIO]
}
}
// tcp, spdy
{
modules: {
transport: [TCP],
streamMuxer: [SPDY],
connEncryption: []
}
}
// websocket, spdy
{
modules: {
transport: [WS],
streamMuxer: [SPDY],
connEncryption: []
}
}
// tcp, spdy, secio
{
modules: {
transport: [TCP],
streamMuxer: [SPDY],
connEncryption: [SECIO]
}
}
// websocket, spdy, secio
{
modules: {
transport: [WS],
streamMuxer: [SPDY],
connEncryption: [SECIO]
}
}
For examples see https://github.com/ipfs/js-ipfs/blob/master/src/core/runtime/libp2p-nodejs.js and https://github.com/ipfs/js-ipfs/blob/master/src/core/runtime/libp2p-browser.js
The connection addresses change only on the transport so you'll be using
/ip4/0.0.0.0/tcp/4012
and
/ip4/0.0.0.0/tcp/4022/ws
...every time.
@alanshaw Thanks!!!
@alanshaw Is there a way to verify the different options after the peer has been started? Like, I want to verify the config was built correctly. Example, verify that a certain test is using SECIO for the encryption?
hmm, you could use the DEBUG
env var to check for secio log messages?
DEBUG=libp2p:secio node test.js
@jacobheun / @vasco-santos is there a better way?
We should probably add a cleaner way to dump the config for libp2p, DEBUG is probably the easiest way right now if you're just trying to do a spot check.
It's a bit noisy but, DEBUG=libp2p:switch:transport,libp2p:conn*,-libp2p:connection-manager
, will show you most of the connection flow. libp2p needs to be >=0.24 for this to yield similar results.
An example log would look like the following, which lets you see the transport being dialed on, encryption and the multiplexer. TCP
, /secio/1.0.0
and /mplex/6.7.0
in this instance.
libp2p:conn:out:QmdhCk4b dialing QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +0ms
libp2p:conn:out:QmdhCk4b dialing transport TCP +8ms
libp2p:switch:transport dialing TCP [ '/ip4/127.0.0.1/tcp/63083/ipfs/QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw',
'/ip4/192.168.178.23/tcp/63083/ipfs/QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw' ] +110ms
libp2p:conn:inc:QmT9wjia successfully privatized incoming connection +0ms
libp2p:conn:inc:QmT9wjia encrypting connection via /secio/1.0.0 +1ms
libp2p:conn:inc:QmT9wjia successfully privatized incoming connection +0ms
libp2p:conn:inc:QmT9wjia encrypting connection via /secio/1.0.0 +1ms
libp2p:conn:out:QmdhCk4b successfully dialed QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +63ms
libp2p:conn:out:QmdhCk4b successfully privatized incoming connection +1ms
libp2p:conn:out:QmdhCk4b selecting crypto /secio/1.0.0 to QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +7ms
libp2p:conn:out:QmdhCk4b successfully encrypted connection to QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +75ms
libp2p:conn:out:QmdhCk4b upgrading connection to QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +7ms
libp2p:conn:inc:QmT9wjia successfully encrypted connection to unknown peer +119ms
libp2p:conn:inc:QmT9wjia adding the protocol muxer to the connection +0ms
libp2p:conn:inc:QmT9wjia successfully muxed connection to unknown peer +0ms
libp2p:conn:out:QmdhCk4b selecting /mplex/6.7.0 +4ms
libp2p:conn:out:QmdhCk4b successfully muxed connection to QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +15ms
libp2p:conn:out:QmdhCk4b new stream created via muxer to QmT9wjiav36aFwqKPrRipU8KV5wkCtZt4AswKXbst2JVNw +16ms
Thanks @alanshaw @jacobheun
@alanshaw Does the go init use libp2p in the config? I can't find exanples how that is configured in go and now I'm getting
{ Error: Command failed: export IPFS_PATH=/var/folders/m_/_3zzzw7d6dx3gsxlrffsw0s80000gn/T/ipfs0 && ipfs swarm connect /ip4/127.0.0.1/tcp/4012/ipfs/QmSxYJBid9EUdV61T9dUELAsc2FncyQWaSEvm4ztcURiur
Error: connect QmSxYJBid9EUdV61T9dUELAsc2FncyQWaSEvm4ztcURiur failure: dial attempt failed: <peer.ID Qm*fYYr23> --> <peer.ID Qm*cURiur> dial attempt failed: protocol not supported
when trying to connect js -> go.
@alanshaw ^^^
I'm going to close this issue out and create a new one specifically for the JS-> go test
New issue here: https://github.com/ipfs/benchmarks/issues/241
Working on some of the different tests and need help verifying the connections protocols match and others I'm not sure yet how to make the connection. Please advise:
(tcp, mplex) -> swarm connection address = "/ip4/0.0.0.0/tcp/4012" (websocket, mplex) ->swarm connection address = "/ip4/0.0.0.0/tcp/4022/ws" (tcp, mplex, secio) -> ???? (websocket, mplex, secio) -> ???? (tcp, spdy) -> ?? (websocket, spdy) -> ?? (tcp, spdy, secio) (websocket, spdy, secio)