This repository has been deprecated.
All examples and tutorials can be found in the examples directory of the go-libp2p repo.
Example libp2p applications
License: MIT License
This repository has been deprecated.
All examples and tutorials can be found in the examples directory of the go-libp2p repo.
steps :
go run chat.go
in first windowgo run chat.go -d /ip4/127.0.0.1/tcp/64717/p2p/QmefMVVk1tZzfYshYVUFpnwNswtqgXrD6geWo3PFUzQX1Q
in second window.go run chat.go -d /ip4/127.0.0.1/tcp/64717/p2p/QmefMVVk1tZzfYshYVUFpnwNswtqgXrD6geWo3PFUzQX1Q
in third window.Then ,when I type any message such as
> aaa
> bbb
Only the second window receive aaa
the third window receive bbb
so, how can they receive all messages ?
credit to @Stebalien for a nice description.
The almost-always works answer is:
Eventually, we'd like to automate the second two pieces but that means we'd need an automated way to find and pick good relays.
UPnP/NATPortMap
When NAT traversal is enabled (in go-libp2p, pass the NATPortMap() option to the libp2p constructor), libp2p will use UPnP and NATPortMap to ask the NAT's router to open and forward a port for libp2p. If your router supports either UPnP or NATPortMap, this is by far the best option.
STUN/hole-punching
LibP2P has it's own version of the "STUN" protocol using peer-routing, external address discovery, and reuseport. LibP2P:
TURN-like protocol
Finally, we have a TURN like protocol called p2p-circuit. This protocol allows libp2p nodes to "proxy" through other p2p nodes. Unfortunately, neither go-libp2p nor js-libp2p announce p2p-circuit addresses at the moment (by default). This means that it doesn't just automagically bypass NATs (yet).
The next steps here are to:
While technically a different issue, this still falls under the category of working around meddlesome middle boxes.
Currently, we don't have any good ways to work around corporate firewalls. However, we have an issue (ipfs/kubo#5251) to enable the websocket listener by default on go-ipfs which will help significantly because this transport supports HTTP proxies out of the box. Note: This won't be fully solved until p2p-circuit becomes fully automatic as proxy support only allows us to dial, not listen.
Hi,
The example code references ipfs nodes for bootstrap peers. Are those "stable"? Can developers use them in their own projects? How to set up our own?
Thanks?
Hello,
Thanks for go-libp2p!
I am learnig how to use go-libp2p and I need your help to resolve problem I have with chat-with-rendezvous example. Here is cli messages I have:
12:19:50.724 INFO rendezvous: Host created. We are: <peer.ID QmnkLm3D> chat.go:107
12:19:50.724 INFO rendezvous: [/p2p-circuit /ip4/127.0.0.1/tcp/6666] chat.go:108
12:19:50.728 WARNI dht: error bootstrapping: failed to find any peer in table dht_bootstrap.go:86
12:19:50.766 WARNI rendezvous: dial attempt failed: no good addresses chat.go:139
12:19:50.766 WARNI rendezvous: dial attempt failed: no good addresses chat.go:139
12:19:50.767 WARNI rendezvous: dial attempt failed: no good addresses chat.go:139
12:19:50.768 WARNI rendezvous: dial attempt failed: no good addresses chat.go:139
12:19:51.155 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmVQKNAd> [/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001]} chat.go:141
12:19:51.155 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmVQKNAd> [/ip4/178.62.158.247/tcp/4001]} chat.go:141
12:19:51.803 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmzaDs64> [/ip4/104.236.76.40/tcp/4001]} chat.go:141
12:19:51.803 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmzaDs64> [/ip6/2604:a880:800:10::4a:5001/tcp/4001]} chat.go:141
12:19:52.513 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmL1KrGM> [/ip4/104.236.179.241/tcp/4001]} chat.go:141
12:19:52.513 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmL1KrGM> [/ip6/2604:a880:1:20::203:d001/tcp/4001]} chat.go:141
12:19:53.334 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmwMKPnu> [/ip6/2400:6180:0:d0::151:6001/tcp/4001]} chat.go:141
12:19:53.334 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmwMKPnu> [/ip4/128.199.219.111/tcp/4001]} chat.go:141
12:20:00.180 INFO rendezvous: Connection established with bootstrap node: {<peer.ID QmQLuvuJ> [/ip4/104.131.131.82/tcp/4001]} chat.go:141
12:20:00.180 INFO rendezvous: Announcing ourselves... chat.go:149
12:20:00.594 WARNI rendezvous: Connection failed: dial attempt failed: no good addresses chat.go:172
12:20:00.598 WARNI rendezvous: Connection failed: dial attempt failed: no good addresses chat.go:172
12:20:00.600 WARNI rendezvous: Connection failed: dial attempt failed: no good addresses chat.go:172
12:20:00.602 WARNI rendezvous: Connection failed: dial attempt failed: no good addresses chat.go:172
12:20:00.602 WARNI rendezvous: Connection failed: dial attempt failed: no good addresses chat.go:172
12:20:00.603 WARNI rendezvous: Connection failed: dial attempt failed: no good addresses chat.go:172
12:24:50.729 WARNI dht: error bootstrapping: failed to find any peer in table dht_bootstrap.go:86
12:29:50.746 WARNI dht: error bootstrapping: failed to find any peer in table dht_bootstrap.go:86
12:34:50.762 WARNI dht: error bootstrapping: failed to find any peer in table dht_bootstrap.go:86
I tried to add bootstrep node from my IPFS node config file like:
$ ./chat -listen /ip4/127.0.0.1/tcp/6666 -peer /ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
but it does not helped.
What is the problem here?
Thanks
Hi,
Thanks for all the examples. They help a lot. I am running into an issue where I am trying to run the chat-with-rendezvous
examples on 2 machines.
Both machines connect to the bootstrap peers just fine and both advertise the meet me here
rendezvous string. However, when using FindPeers
I get back 0 peers. The example only works if i run both peers on the same machine or on the same network.
Some friends and I are trying to learn more about libp2p by building a dummy app that advertises file hashes via discovery.Advertise
and find them using discovery.FindPeers
. However, we run into the above issue as we sit behind NATs.
Once we do have the peer ID we know how to connect to each other using circuit-relay
. Its just a matter of discovering the peer that advertises the hash which blocks us at the moment.
I'm using protocol buffers to transfer a file through inet.Stream. Any files < 9mb are successfully being sent and received on the other end. If I send a file > 9mb they throw an error write tcp4 10.141.13.74:4001->10.141.13.74:4002: write: protocol wrong type for socket
or write tcp4 10.141.12.222:4001->10.141.12.222:4002: write: broken pipe
Is this a tcp limitation? Any alternative approach to transfer files through inet.Stream. Thanks
when i follow examplex-echo,in the 2nd terminal, i got the error:
2018/10/29 17:00:06 I am /p2p-circuit/ipfs/QmSNfGzsTDf7RDUtXiZSbmyEqz5tawrtkn7DrQ5GxeYNUM
2018/10/29 17:00:06 Now run "./echo -l 10002 -d /p2p-circuit/ipfs/QmSNfGzsTDf7RDUtXiZSbmyEqz5tawrtkn7DrQ5GxeYNUM -secio" on a different terminal
2018/10/29 17:00:06 opening stream
17:00:06.157 INFO swarm2: got error on dial to /p2p-circuit: <peer.ID QmxeYNUM> --> <peer.ID QmkzqPAp> dial attempt failed: Failed to dial through 0 known relay hosts swarm_dial.go:382
2018/10/29 17:00:06 dial attempt failed: <peer.ID QmxeYNUM> --> <peer.ID QmkzqPAp> dial attempt failed: Failed to dial through 0 known relay hosts
The current host example doesn't default to becoming a self-sustaining DHT mesh. It would be useful to add an example using the Dual
DHT from go-libp2p-kad-dht
to demonstrate that configuration.
All of the examples have out of date, for example.
SetStreamHandler
doesn't allow a func for it's second argument.
rt,and if can work, does it use some public relay node or direct connect?
I was trying out the examples and it panics at the following line with the error protocol not supported.
stream, err := node.NewStream(ctx, peer.ID, protocol.ID("/plaintext/2.0.0"))
I tried the one mentioned in the example "/chat/1.0.0" as well. Where do I define this ?
While running:
go get github.com/libp2p/go-libp2p-examples/chat-with-rendezvous
I encounter this error:
# github.com/libp2p/go-libp2p-record/pb
/Users/weichen/go/src/github.com/libp2p/go-libp2p-record/pb/record.pb.go:68:28: undefined: proto.InternalMessageInfo
Based on these issues:
grpc/grpc-go#2095
googleapis/go-genproto#77
The first thing that I should try is:
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
But after getting the new proto
and protoc-gen-go
, I still get the same error.
Then I try to delete the current protobuf src dir based on this issue golang/protobuf#642
But apparently, it still doesn't help. (still get the same error while running the first script)
The current environment that I am using is go1.11
, which is the latest version of Go already.
when i run relay example in https://github.com/libp2p/go-libp2p-examples/tree/master/relay i get two errors
h1, err := libp2p.New(context.Background(), libp2p.EnableRelay(circuit.OptDiscovery))
error iscircuit.OptDiscovery is now a no-op: dialing peers with a random relay is no longer supported
relayaddr, err := ma.NewMultiaddr("/p2p-circuit/p2p/"+ h3.ID().Pretty())
report an't dial a p2p-circuit without specifying a relay: /p2p-circuit/p2p/QmPTjoYNMLSR8wzeRToMCwokMqCjz1TwBTdbJq7nX4TsWN
so how to use the libp2p-circuit ? or any other examples?
final i get these fixed by set
relayaddr, err := ma.NewMultiaddr("/p2p/"+h2.ID().Pretty()+"/p2p-circuit/p2p/"+ h3.ID().Pretty())
The code below is in chat.go:
// If debug is enabled, use a constant random source to generate the peer ID. Only useful for debugging,
// off by default. Otherwise, it uses rand.Reader.
var r io.Reader
if *debug {
// Use the port number as the randomness source.
// This will always generate the same host ID on multiple executions, if the same port number is used.
// Never do this in production code.
r = mrand.New(mrand.NewSource(int64(*sourcePort)))
} else {
r = rand.Reader
}
// Creates a new RSA key pair for this host.
prvKey, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)
if err != nil {
panic(err)
}
While this seems reasonable, in fact crypto.GenerateKeyPairWithReader calls the default go RSA implementation which went out of its way to make doing this basically disallowed. The first line of the RSA implementation in Go is randutil.MaybeReadByte(random)
, which has the following comment:
// MaybeReadByte reads a single byte from r with ~50% probability. This is used
// to ensure that callers do not depend on non-guaranteed behaviour, e.g.
// assuming that rsa.GenerateKey is deterministic w.r.t. a given random stream.
//
// This does not affect tests that pass a stream of fixed bytes as the random
// source (e.g. a zeroReader).
Two questions:
I have written a basic pubsub with bootstrap example using golang.
I am unable to connect to a node in different network sometimes,
I added NATPortMap to the new constructor while creating the node.
Here is the code
https://gist.github.com/rahullenkala/097fa1b0178a6fe9d275c506014c014c
go run host.go happen the error
After the host with its []ma.Multiaddr
addresses were kadDht.Provide
provided and kadDht.FindProviders
found again by the same host the addresses were lost
The default rendezvousString
did not work well for me.
Instead, I use a UUID as rendezvousString
and it did work better. But, after a restart, I get errors concerning the old peers:
dial attempt failed: <peer.ID Qm*QscaEK> --> <peer.ID Qm*dFxmP9> dial attempt failed: connection refused
dial backoff
Using a new UUID, there are no errors.
How can I remove peers from kadDht
? I tried it with contexts and methods, but without success. How can it be done?
Right now, using the chat example, we shut down all the nodes if you kill one of them. Does anyone knows how to relay the info in Peer Store to connected nodes automatically if one node dies ? ( So they can connect to each other)
When going through the examples I found myself creating a package.json
for each example using gx
. Unless the imports in the examples are re-written the binaries don't build. I'd like to upstream the Makefiles and the package.json
files and save other users the time.
Let me know if you think this is a good/bad idea, thanks! @vyzo @raulk @Stebalien
PeerInfo
got from FindPeers has EMPTY Addrs.bootnode: A
node: B
node: C
B and C all connected to bootnode A.
B called discovery.Advertise(somestring)
, then C call routingDiscovery.FindPeers(somestring)
, it can get PeerInfo with B's ID and Addrs.
But after maybe 10 minutes, C call routingDiscovery.FindPeers(somestring)
only get PeerInfo with B's ID but has no Addrs, the node B is online when C calledroutingDiscovery.FindPeers(somestring)
.
After reboot B, C can get Addrs from routingDiscovery.FindPeers(somestring)
immediatly.
#ls
proxy.go README.md
#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o http-proxy proxy.go
# github.com/libp2p/go-reuseport
/root/go/src/github.com/libp2p/go-reuseport/impl_wasm.go:10:53: listen redeclared in this block
previous declaration at /root/go/src/github.com/libp2p/go-reuseport/impl_unix.go:211:45
/root/go/src/github.com/libp2p/go-reuseport/impl_wasm.go:14:56: listenPacket redeclared in this block
previous declaration at /root/go/src/github.com/libp2p/go-reuseport/impl_unix.go:291:61
/root/go/src/github.com/libp2p/go-reuseport/impl_wasm.go:18:53: listenStream redeclared in this block
previous declaration at /root/go/src/github.com/libp2p/go-reuseport/impl_unix.go:260:59
/root/go/src/github.com/libp2p/go-reuseport/impl_wasm.go:22:87: dial redeclared in this block
previous declaration at /root/go/src/github.com/libp2p/go-reuseport/impl_unix.go:62:87
/root/go/src/github.com/libp2p/go-reuseport/impl_wasm.go:26:18: available redeclared in this block
previous declaration at /root/go/src/github.com/libp2p/go-reuseport/available_unix.go:23:18
**how to create my own bootstrap peer like DefaultBootstrapPeers in github.com/libp2p/go-libp2p-kad-dht/dht_bootstrap.go:16 **
In the chat-with-rendezvous example, I tried to use a chat-with-rendezvous instance as a bootstrap. For nodes in other networks, the peer parameter points to it.
Peers in the same network can be interconnected, and different networks can't communicate. If all nodes use the default dht.DefaultBootstrapPeers, different networks can communicate.
cd $GOPATH/src/github.com/libp2p/go-libp2p-host && gx-go rw --fix
? not fix
~/go/src/github.com/libp2p/go-libp2p-examples/http-proxy#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o http-proxy proxy.go
# command-line-arguments
./proxy.go:37:2: cannot use host (type "gx/ipfs/QmaoXrM4Z41PD48JY36YqQGKQpLGjyLA2cKcLsES7YddAq/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in return argument:
"gx/ipfs/QmaoXrM4Z41PD48JY36YqQGKQpLGjyLA2cKcLsES7YddAq/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
I can't run ipfs-camp-2019 examples by using the instructions provided. It seems that the examples need a running peer at 63785 port, But no instruction is provided for running that peer.
Hi,
On the pubsub\chat example, i'm able to build and run different clients but when i send a message, i only see the message in my CMD, not in the others CMDs.
Also i don't see the other users in the "Peers" column.
Is there something to change maybe with the IP or port ?
Thanks :)
Hello.
I completed these steps:
I have the following errors:
$GOPATH\src\github.com\libp2p\go-libp2p-examples\chat-with-rendezvous>go build chat.go
# command-line-arguments
.\chat.go:98:24: cannot use handleStream (type func("github.com/libp2p/go-libp2p-net".Stream)) as type "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net".StreamHandler in argument
to host.SetStreamHandler
.\chat.go:100:24: cannot use host (type "gx/ipfs/QmeA5hsqgLryvkeyqeQdvGDqurLkYi3XEPLZP3pzuBJXh2/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in argument to dht.New:
"gx/ipfs/QmeA5hsqgLryvkeyqeQdvGDqurLkYi3XEPLZP3pzuBJXh2/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
.\chat.go:110:31: cannot use *peerinfo (type "github.com/libp2p/go-libp2p-peerstore".PeerInfo) as type "gx/ipfs/QmfAQMFpgDU2U4BXG64qVr8HSiictfWvkSBz7Y2oDj65st/go-libp2p-peerstore".PeerInfo in argument to host.Connect
.\chat.go:147:11: invalid operation: p.ID == host.ID() (mismatched types "github.com/libp2p/go-libp2p-peer".ID and "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer".ID)
.\chat.go:152:39: cannot use p.ID (type "github.com/libp2p/go-libp2p-peer".ID) as type "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer".ID in argument to host.NewStream
$GOPATH\src\github.com\libp2p\go-libp2p-examples\chat-with-rendezvous>
Thank you guys for your amazing project. I've started diving to it recently and a small question appeared in my mind. In multipro example you create stream on every message node send, so is it better to use approach like in multipro or it is better to use the one stream for one protocol?
I'm trying to use chat-with-mdns with two instances in AWS. The default host 0.0.0.0 is applied and same ports used on both the instances. The ports are open to the public internet (verified) but the two don't seem to identify each other.
Am I missing something? Or this mdns discovery only works for local router setup only?
running nodeA and nodeB、nodeC,nodeB connect to NodeA,NodeC connect nodeA,when i shutdown NodeB,NodeA immediately close,and NodeC also immediately close,how todo shutdown NodeB and NodeC->NodeA was keep connnect?
ha.SetStreamHandler("/p2p/1.0.0", handleStream)
select {} // hang forever
chat-with-rendezvous
example defined a default bootstrap node list , how can I make my PC as the bootstrap node?
...
kadDht,err:=dht.New(ctx,host)
if err !=nil {
panic(err)
}
//Will this work???
err=kadDht.Bootstrap(ctx)
if err !=nil {
panic(err)
}
...
Hello!
I completed these steps:
1.
mkdir /tmp/libp2p-examples
export GOPATH=/tmp/libp2p/examples
It shows me that
# github.com/libp2p/go-reuseport
/tmp/libp2p/examples/src/github.com/libp2p/go-reuseport/interface.go:33:20: undefined: net.ListenConfig
/tmp/libp2p/examples/src/github.com/libp2p/go-reuseport/interface.go:41:2: not enough arguments to return
/tmp/libp2p/examples/src/github.com/libp2p/go-reuseport/interface.go:48:2: not enough arguments to return
/tmp/libp2p/examples/src/github.com/libp2p/go-reuseport/interface.go:60:10: unknown field 'Control' in struct literal of type net.Dialer
Is anything possibly wrong with my go version or package installing?
Extending basic chat
example to include peer discovery using IPFS bootstrapping nodes and a rendezvous point to connect with other peers. This is important because current example needs manual connection by giving a peer address hence its confusing.
This example will demonstrate a simple p2p host with default transport and peer discovery mechanism and how to open a new stream once peers are found.
@bigs is also working on an example (#1) that will explore adding a custom transport (Onion transport) and using floodsub
protocol for chatting. Which is more practical for chat usecase.
In your examples(chat, chat-with-rendezvous) we can give only loopback address(127.0.0.1) instead our real ip address(public ip).
I tested without router but it remains printed error. So this is not real application because we can chat on only local environment.
Do you know why can't I give a opposite public ip address?
One more question:
There are three peers connected each other. It destroy all connections if a peer terminate own process(ex. Ctrl+C)
Even if a peer terminate own process, other guys(2 peers) should not impact about that and remains connected between 2 peers. I think that 2 peers should receive EOF if a peer close his socket(process termination), however this example was not working as my guess
I started 4 chat-with-rendezvous
locally with port 3000, 4000, 5000, 6000 respectively.
./chat -listen /ip4/127.0.0.1/tcp/3000
My forked example repo: https://github.com/lzl124631x/go-libp2p-examples/commit/adb0eb38bef472749742ada537c431490c019005
Sometimes I saw log like this:
20:20:39.958 INFO rendezvous: Connected to: {<peer.ID Qm*UB48gJ> []} chat.go:183
while other times I saw:
20:20:59.372 INFO rendezvous: Connected to: {<peer.ID Qm*UB48gJ> [/p2p-circuit /ip4/127.0.0.1/tcp/3000 /ip4/73.225.14.166/tcp/3000]} chat.go:183
So sometimes I can see the multiaddr but sometimes not. Why?
I saw message like this:
// For node 5000
20:33:51.088 INFO rendezvous: Host created. I'm /ip4/127.0.0.1/tcp/5000/ipfs/Qmf4Rh2JY5DfPMrR2YjKUsLhAoeG6X4cKfTxiR1NrVaHW3 chat.go:107
20:33:57.021 INFO rendezvous: Got a new stream! local /ip4/127.0.0.1/tcp/5000 remote /ip4/127.0.0.1/tcp/59919 chat.go:25
// For node 6000
20:33:57.021 INFO rendezvous: Connected to: local [/p2p-circuit /ip4/127.0.0.1/tcp/6000] remote {<peer.ID Qm*rVaHW3> []} chat.go:183
20:35:54.115 INFO rendezvous: Got a new stream! local /ip4/127.0.0.1/tcp/59919 remote /ip4/127.0.0.1/tcp/5000 chat.go:25
Why was there a host with port 59919
created for 5000
?
Trying to build an example but got the following errors,
…
go: finding github.com/libp2p/go-stream-muxer v3.0.1+incompatible
go: github.com/libp2p/[email protected]: unknown revision v0.1.16
go: finding github.com/libp2p/go-libp2p-routing v2.7.1+incompatible
go: github.com/libp2p/[email protected]: unknown revision v0.0.21
go: finding github.com/libp2p/go-libp2p-nat v0.8.8
go: github.com/libp2p/[email protected]: unknown revision v0.1.15
go: finding github.com/libp2p/go-addr-util v2.0.7+incompatible
go: github.com/libp2p/[email protected]: unknown revision v0.2.30
go: finding github.com/libp2p/go-libp2p-peer v2.4.0+incompatible
go: github.com/multiformats/[email protected]: unknown revision v1.4.0
go: finding github.com/libp2p/go-libp2p-metrics v2.1.7+incompatible
go: github.com/libp2p/[email protected]+incompatible: unknown revision v2.0.5
go: finding github.com/libp2p/go-libp2p-peerstore v2.0.6+incompatible
go: github.com/multiformats/[email protected]: unknown revision v1.7.1
go: finding github.com/libp2p/go-libp2p-host v3.0.15+incompatible
go: github.com/libp2p/[email protected]+incompatible: unknown revision v3.0.22
go: finding github.com/libp2p/go-libp2p-record v4.1.7+incompatible
go: github.com/libp2p/[email protected]+incompatible: unknown revision v3.0.1
go: github.com/libp2p/[email protected]+incompatible: unknown revision v2.7.1
go: github.com/libp2p/[email protected]+incompatible: unknown revision v2.4.0
go: github.com/libp2p/[email protected]+incompatible: unknown revision v6.0.29
go: github.com/libp2p/[email protected]: unknown revision v0.8.8
go: github.com/libp2p/[email protected]+incompatible: unknown revision v4.1.7
go: github.com/libp2p/[email protected]+incompatible: unknown revision v2.0.7
go: github.com/libp2p/[email protected]+incompatible: unknown revision v2.1.7
go: github.com/libp2p/[email protected]+incompatible: unknown revision v3.0.15
go: github.com/libp2p/[email protected]+incompatible: unknown revision v2.0.6
go: error loading module requirements
Compiling and running the binaries works fine. However, when I try to debug the code I get a panic on the server side, immediately after the client connects.
Panic:
Run './chat -d /ip4/127.0.0.1/tcp/3001/ipfs/QmcxsSTeHBEfaWBb2QKe5UZWK8ezWJkxJfmcb5rQV374M6' on another console.
You can replace 127.0.0.1 with public IP as well.
Waiting for incoming connection
2018/08/13 15:27:23 Got a new stream!
> panic: EOF
goroutine 37 [running]:
main.writeData(0xc42043a0c0)
/home/me/go/Workspace4/src/github.com/libp2p/go-libp2p-examples/chat/chat.go:122 +0x36b
created by main.handleStream
/home/me/go/Workspace4/src/github.com/libp2p/go-libp2p-examples/chat/chat.go:94 +0x190
Debugger finished with exit code 0
Problems seems to be that the stdReader
in writeData()
receives no bytes in stdReader.ReadString('\n')
Can somebody explain/reproduce this or has a solution? Debugging would be nice to follow and understand the program's control flow.
(Debugging of the echo example works and doesn't cause a panic.)
go-libp2p-examples/chat
513da5f
go-libp2p
libp2p/go-libp2p@163d7d4
Can't start a chat on a two different devices in one local network (wi-fi)
They are not see each other
first device is linux, second is windows
1、in my nat lan host(A)
http-proxy
p2p Key,like
abcdef999999
2、my remoute pc host(B)
#./http-proxy -d /ip4/127.0.0.1/tcp/12000/ipfs/abcdef999999
Proxy server is ready
libp2p-peer addresses:
/p2p-circuit/ipfs/abcdef999999
/ip4/127.0.0.1/tcp/12001/ipfs/abcdef999999
proxy listening on 127.0.0.1:9900
3、test
#curl -x "127.0.0.1:9900" "http://ipfs.io/ipfs/abcdef999999"
dial attempt failed: <peer.ID Qm*oYtu85> --> <peer.ID Qm*k8syvm> dial attempt failed: connection refused
local server err
proxying request for http://ipfs.io/ipfs/abcdef999999 to peer abcdef999999
2019/01/07 12:55:39 dial attempt failed: <peer.ID Qm*7Uecfu> --> <peer.ID Qm*k8syvm> dial attempt failed: connection refused
curl -x "127.0.0.1:9900" http://172.17.1.2:80/
proxying request for http://172.17.1.2:80/ to peer abcdef999999
2019/01/07 12:57:34 dial backoff
Hi folks,
I'm currently working on a project where I want to expose my IoT device settings to the internet via a web application.
Because I have a large number of devices I wanted to create a maintainable solution for them all.
All the devices have different interfaces and settings which are impossible to maintain building a custom solution for them all. So I tried to figure out how I can manage settings from a web portal by creating a (sidecar) proxy to all the individual devices.
Is there any proper solution for this or am I missing a step doing the proxy example? The proxy is doing it in the wrong way which is not useable for my case. How can I do this in reverse?
To make my case more clear I made sort of a diagram where I explain what my thoughts currently are.
libp2p is cool, I am studying it , and want to use the example "http-proxy" to build my own proxy.
However, I find it only works for http website, not for the https website.
I check the code, which use DefaultTransport to forward https request. And, I am not sure whether the problem occurs here.
cannot use peerhost (type "github.com/libp2p/go-libp2p-core/host".Host) as type "github.com/libp2p/go-libp2p-host".Host in argument to discovery.NewMdnsService:
"github.com/libp2p/go-libp2p-core/host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for ConnManager method)
have ConnManager() connmgr.ConnManager
want ConnManager() ifconnmgr.ConnManager
Would be really helpful to have an example using ymux or mplex
Introduced in #40:
go: downloading github.com/jackpal/go-nat-pmp v1.0.1
go: downloading golang.org/x/text v0.3.0
go: downloading github.com/whyrusleeping/mdns v0.0.0-20180901202407-ef14215e6b30
go: finding github.com/miekg/dns v1.1.4
go: downloading github.com/miekg/dns v1.1.4
# github.com/miekg/dns
../../../../pkg/mod/github.com/miekg/[email protected]/dnssec_keyscan.go:184:18: undefined: ed25519.SeedSize
../../../../pkg/mod/github.com/miekg/[email protected]/dnssec_keyscan.go:187:8: undefined: ed25519.NewKeyFromSeed
../../../../pkg/mod/github.com/miekg/[email protected]/dnssec_privkey.go:85:24: p.Seed undefined (type ed25519.PrivateKey has no field or method Seed)
CircleCI: https://circleci.com/gh/libp2p/go-libp2p-examples/12
I try to run two different terminal windows with the example of chat-with-mdns, but failed to connect with each other. I don't know something I have not configure will on my computer, Is this example use udp protocol to broadcast the node's information?
It would be very grateful if you can tell me your suggestions! Thank you!
I got the following error when building
Minhs-MacBook-Pro:go-libp2p-examples minhdoan$ make deps
go get -t -d ./...
Minhs-MacBook-Pro:go-libp2p-examples minhdoan$ go build ./...
# github.com/libp2p/go-libp2p-examples/protocol-multiplexing-with-multicodecs
protocol-multiplexing-with-multicodecs/main.go:83:2: cannot use h (type "gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in return argument:
"gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
# github.com/libp2p/go-libp2p-examples/chat
chat/chat.go:158:21: cannot use sourceMultiAddr (type "github.com/multiformats/go-multiaddr".Multiaddr) as type "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr in argument to libp2p.ListenAddrs:
"github.com/multiformats/go-multiaddr".Multiaddr does not implement "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr (wrong type for Decapsulate method)
have Decapsulate("github.com/multiformats/go-multiaddr".Multiaddr) "github.com/multiformats/go-multiaddr".Multiaddr
want Decapsulate("gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr) "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
chat/chat.go:159:18: cannot use prvKey (type "github.com/libp2p/go-libp2p-crypto".PrivKey) as type "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey in argument to libp2p.Identity:
"github.com/libp2p/go-libp2p-crypto".PrivKey does not implement "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey (wrong type for Equals method)
have Equals("github.com/libp2p/go-libp2p-crypto".Key) bool
want Equals("gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".Key) bool
chat/chat.go:170:25: cannot use handleStream (type func("github.com/libp2p/go-libp2p-net".Stream)) as type "gx/ipfs/QmenvQQy4bFGSiHJUGupVmCRHfetg5rH3vTp9Z2f6v2KXR/go-libp2p-net".StreamHandler in argument to host.SetStreamHandler
chat/chat.go:212:33: cannot use info.ID (type "github.com/libp2p/go-libp2p-peer".ID) as type "gx/ipfs/QmcqU6QUDSXprb1518vYDGczrTJTyGwLG9eUa5iNX4xUtS/go-libp2p-peer".ID in argument to host.Peerstore().AddAddrs
chat/chat.go:212:42: cannot use info.Addrs (type []"github.com/multiformats/go-multiaddr".Multiaddr) as type []"gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr in argument to host.Peerstore().AddAddrs
chat/chat.go:216:54: cannot use info.ID (type "github.com/libp2p/go-libp2p-peer".ID) as type "gx/ipfs/QmcqU6QUDSXprb1518vYDGczrTJTyGwLG9eUa5iNX4xUtS/go-libp2p-peer".ID in argument to host.NewStream
# github.com/libp2p/go-libp2p-examples/libp2p-host
libp2p-host/host.go:36:18: cannot use priv (type "github.com/libp2p/go-libp2p-crypto".PrivKey) as type "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey in argument to libp2p.Identity:
"github.com/libp2p/go-libp2p-crypto".PrivKey does not implement "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey (wrong type for Equals method)
have Equals("github.com/libp2p/go-libp2p-crypto".Key) bool
want Equals("gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".Key) bool
# github.com/libp2p/go-libp2p-examples/echo
echo/main.go:48:18: cannot use priv (type "github.com/libp2p/go-libp2p-crypto".PrivKey) as type "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey in argument to libp2p.Identity:
"github.com/libp2p/go-libp2p-crypto".PrivKey does not implement "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey (wrong type for Equals method)
have Equals("github.com/libp2p/go-libp2p-crypto".Key) bool
want Equals("gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".Key) bool
echo/main.go:66:30: cannot use hostAddr (type "github.com/multiformats/go-multiaddr".Multiaddr) as type "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr in argument to addr.Encapsulate:
"github.com/multiformats/go-multiaddr".Multiaddr does not implement "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr (wrong type for Decapsulate method)
have Decapsulate("github.com/multiformats/go-multiaddr".Multiaddr) "github.com/multiformats/go-multiaddr".Multiaddr
want Decapsulate("gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr) "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
echo/main.go:74:2: cannot use basicHost (type "gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in return argument:
"gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
# github.com/libp2p/go-libp2p-examples/http-proxy
http-proxy/proxy.go:38:2: cannot use host (type "gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in return argument:
"gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
# github.com/libp2p/go-libp2p-examples/chat-with-rendezvous
chat-with-rendezvous/chat.go:98:24: cannot use handleStream (type func("github.com/libp2p/go-libp2p-net".Stream)) as type "gx/ipfs/QmenvQQy4bFGSiHJUGupVmCRHfetg5rH3vTp9Z2f6v2KXR/go-libp2p-net".StreamHandler in argument to host.SetStreamHandler
chat-with-rendezvous/chat.go:100:24: cannot use host (type "gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in argument to dht.New:
"gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
chat-with-rendezvous/chat.go:110:31: cannot use *peerinfo (type "github.com/libp2p/go-libp2p-peerstore".PeerInfo) as type "gx/ipfs/QmQAGG1zxfePqj2t7bLxyN8AFccZ889DDR9Gn8kVLDrGZo/go-libp2p-peerstore".PeerInfo in argument to host.Connect
chat-with-rendezvous/chat.go:147:11: invalid operation: p.ID == host.ID() (mismatched types "github.com/libp2p/go-libp2p-peer".ID and "gx/ipfs/QmcqU6QUDSXprb1518vYDGczrTJTyGwLG9eUa5iNX4xUtS/go-libp2p-peer".ID)
chat-with-rendezvous/chat.go:152:39: cannot use p.ID (type "github.com/libp2p/go-libp2p-peer".ID) as type "gx/ipfs/QmcqU6QUDSXprb1518vYDGczrTJTyGwLG9eUa5iNX4xUtS/go-libp2p-peer".ID in argument to host.NewStream
# github.com/libp2p/go-libp2p-examples/multipro
multipro/main.go:23:21: cannot use listen (type "github.com/multiformats/go-multiaddr".Multiaddr) as type "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr in argument to libp2p.ListenAddrs:
"github.com/multiformats/go-multiaddr".Multiaddr does not implement "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr (wrong type for Decapsulate method)
have Decapsulate("github.com/multiformats/go-multiaddr".Multiaddr) "github.com/multiformats/go-multiaddr".Multiaddr
want Decapsulate("gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr) "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
multipro/main.go:24:18: cannot use priv (type "github.com/libp2p/go-libp2p-crypto".PrivKey) as type "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey in argument to libp2p.Identity:
"github.com/libp2p/go-libp2p-crypto".PrivKey does not implement "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".PrivKey (wrong type for Equals method)
have Equals("github.com/libp2p/go-libp2p-crypto".Key) bool
want Equals("gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto".Key) bool
multipro/main.go:27:16: cannot use host (type "gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host) as type "github.com/libp2p/go-libp2p-host".Host in argument to NewNode:
"gx/ipfs/QmahxMNoNuSsgQefo9rkpcfRFmQrMN6Q99aztKXf63K7YJ/go-libp2p-host".Host does not implement "github.com/libp2p/go-libp2p-host".Host (wrong type for Addrs method)
have Addrs() []"gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr".Multiaddr
want Addrs() []"github.com/multiformats/go-multiaddr".Multiaddr
Hi,
I am noob to libp2p. I am trying to figure out how to setup a peer-to-peer network for a blockchain. During my exploration I came across go libp2p examples repository and I tried to execute "Chat with Rendezvous" example but I couldn't connect to a node on a different network apart from my local network.
Please guide me in getting over this issue and understand libp2p to the greater extent especially with routing and discovery aspects.
NODE 1 (Local Network)
NODE 2 (Local Network)
NODE 3 (Different network)
It would be very nice to see if we could have a demo example of working with pubsub mechanism in this repo 🤞
For example it could be some simple group chat application
Hi,
I fired up a simple-bootstrap-node on a server of mine.
Then a friend of mine in another city and I compiled chat-with-rendezvous as described and ran it (./chat -peer <string/from/bootstrap/node> -rendezvous testing).
Our consoles connect successfully to the bootstrap-node and print "Announcing ourselves" and then we get either nothing (literally nothing) or some warnings (they find each other but can't connect).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.