libp2p / go-libp2p-examples

Example libp2p applications
MIT License
338 stars 145 forks source link

mDNS example #2

Closed gpestana closed 5 years ago

gpestana commented 6 years ago

Was playing around with libp2p mDNS implementation and decided to create this example. Feedback is welcome :)

upperwal commented 6 years ago

I think this repo should not depend on gx. People should directly go get libp2p and use these examples.

zigo101 commented 6 years ago

Ok, moved from https://github.com/libp2p/go-libp2p/issues/379 to here.

I made small modifications on this PR so that I can run two different instances on two machines in the same local network. It looks the two peer instances can discover each other but couldn't connect to each other.

The modified version: https://play.golang.org/p/eMeQ0Gh33aA

Output on one machine:

$ ./go-p2p 

host QmP4wqKpfv3fWsFZymccG66jsiLTwGe9qF2pVYWG6d6CWZ knows:
 >> QmP4wqKpfv3fWsFZymccG66jsiLTwGe9qF2pVYWG6d6CWZ

host <peer.ID P4wqKp> connecting to <peer.ID XwzNjE>... (blocking)
Error when connecting peers: dial attempt failed: <peer.ID P4wqKp> --> <peer.ID XwzNjE> dial attempt failed: connection refused

host QmP4wqKpfv3fWsFZymccG66jsiLTwGe9qF2pVYWG6d6CWZ knows:
 >> QmP4wqKpfv3fWsFZymccG66jsiLTwGe9qF2pVYWG6d6CWZ
 >> QmXwzNjEsTnExHjWD39M8oSbG4iKKU5WSapJGayV5QmrPk

Output on the other machine

$ ./go-p2p -port=8001

host QmXwzNjEsTnExHjWD39M8oSbG4iKKU5WSapJGayV5QmrPk knows:
 >> QmXwzNjEsTnExHjWD39M8oSbG4iKKU5WSapJGayV5QmrPk

host <peer.ID XwzNjE> connecting to <peer.ID P4wqKp>... (blocking)
Error when connecting peers: dial attempt failed: <peer.ID XwzNjE> --> <peer.ID P4wqKp> dial attempt failed: context deadline exceeded

host <peer.ID XwzNjE> connecting to <peer.ID P4wqKp>... (blocking)
Error when connecting peers: dial backoff

host QmXwzNjEsTnExHjWD39M8oSbG4iKKU5WSapJGayV5QmrPk knows:
 >> QmXwzNjEsTnExHjWD39M8oSbG4iKKU5WSapJGayV5QmrPk
 >> QmP4wqKpfv3fWsFZymccG66jsiLTwGe9qF2pVYWG6d6CWZ

Any mistakes in my modified version? Or the peer hosts need more options?

Stebalien commented 6 years ago

Possibly a firewall issue?

gpestana commented 6 years ago

@upperwal yes, sounds reasonable. I will remove the gx setup and update the PR.

@go101 connection refused seems like something is blocking the connections?

zigo101 commented 6 years ago

@Stebalien @gpestana No firewalls are installed on both machines. does it run well in your network environments?

anacrolix commented 5 years ago

I'll close this due to age. I just merged #33, which also deals with mDNS, FWIW. Please re-open if there's renewed interest in getting this in.