GithubHelp home page GithubHelp logo

Comments (4)

vyzo avatar vyzo commented on July 23, 2024

That's because of a recent change in libp2p, which enables relay by default. The code is faulty and blindly uses the first address, which happens to be a relay address.

Possible solutions:

  • pass libp2p.DisableRelay() to libp2p.New to turn off relay
  • fix the code to be more clever about the use of addresses and don't try to dial the relay address.

edit: the simplest solution is to print all addrs in the I am ... part, not just the first address.

from go-libp2p-examples.

hot3246624 avatar hot3246624 commented on July 23, 2024

That's because of a recent change in libp2p, which enables relay by default. The code is faulty and blindly uses the first address, which happens to be a relay address.

Possible solutions:

  • pass libp2p.DisableRelay() to libp2p.New to turn off relay
  • fix the code to be more clever about the use of addresses and don't try to dial the relay address.

edit: the simplest solution is to print all addrs in the I am ... part, not just the first address.

it is not ok for me, when i dial other address such as 127.0.10.1, the error is:
19:53:38.817 WARNI swarm2: listen on /ip4/127.0.10.1/tcp/10000 failed: listen tcp4 127.0.10.1:10000: bind: can't assign requested address swarm_listen.go:25
19:53:38.817 WARNI swarm2: swarm listener accept error: process closing swarm_listen.go:77
2018/10/29 19:53:38 failed to listen on any addresses: [listen tcp4 127.0.10.1:10000: bind: can't assign requested address]

when i pass disableRelay() after libp2p.new, there is nothing change. And i cannot understand the the last word。

from go-libp2p-examples.

cchx0000 avatar cchx0000 commented on July 23, 2024

pass libp2p.DisableRelay() to libp2p.New to turn off relay

this indeed worked as I added opts = append(opts, libp2p.DisableRelay())
Thank you @vyzo

from go-libp2p-examples.

stefanhans avatar stefanhans commented on July 23, 2024

For me, this does the trick:

// Range over the addresses to find the first non relay address
for _, addr := range basicHost.Addrs() {
  if strings.SplitN(addr.String(), "/", 3)[1] != "p2p-circuit" {

    // Now we can build a full multiaddress to reach this host
    // by encapsulating both addresses:
      fullAddr := addr.Encapsulate(hostAddr)
      log.Printf("I am %s\n", fullAddr)
      if secio {
        log.Printf("Now run \"./echo -l %d -d %s -secio\" on a different terminal\n", 
					listenPort+1, fullAddr)
      } else {
        log.Printf("Now run \"./echo -l %d -d %s\" on a different terminal\n", 
					listenPort+1, fullAddr)
      }
    }
  }

Is it a realistic scenario to have a relay and not to use it?

Cheers, Stefan

from go-libp2p-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.