Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make dht reconnect after network fault #294

Closed
avbasov opened this issue Mar 11, 2019 · 5 comments
Closed

How to make dht reconnect after network fault #294

avbasov opened this issue Mar 11, 2019 · 5 comments
Assignees
Labels
kind/support A question or request for support

Comments

@avbasov
Copy link
Contributor

avbasov commented Mar 11, 2019

I have a problem with a DHT peer. It stops working after network faults.

  1. I connect a peer from my laptop to a p2p network on Digital Ocean droplet. And it works perfectly fine.
  2. Then I turn off WiFi on the laptop and wait for a bootstrap error dht: error bootstrapping: failed to find any peer in table.
  3. I turn WiFi on, but the peer doesn't reconnect to the p2p network and keeps writing the same error about empty peer table.

Could you, please, tell me what the proper way to restore connectivity is?

Here is a simplified code

ctx := context.Background()
ipfsLogLevel, _ := logging.LogLevel("DEBUG")
ipfsLog.SetAllLoggers(ipfsLogLevel)

host, _ := libp2p.New(ctx)
dht, _ := kadDHT.New(ctx, host)

host.Connect(ctx, seedPeer)
dht.BootstrapOnce(ctx, kadDHT.DefaultBootstrapConfig)

cfg := kadDHT.DefaultBootstrapConfig
cfg.Period = 30 * time.Second
dht.BootstrapWithConfig(ctx, cfg)

<-ctx.Done()
@raulk
Copy link
Member

raulk commented Mar 11, 2019

@anacrolix is the best person to dig into this.

@anacrolix
Copy link
Contributor

Hi @avbasov . #254 and #283 are related to this. In the meanwhile, you'll have to manually reconnect to the seed peers. You might do this periodically, or when network conditions change, or when you get failed to find any peer in table errors. In #254 (comment), I mention fallback nodes, I think this issue is sufficient to prompt a stand-alone issue for that feature.

@anacrolix
Copy link
Contributor

I've proposed the fix in #295. I'll leave this issue open for a while for any questions you have about workarounds.

@anacrolix anacrolix added the kind/support A question or request for support label Mar 11, 2019
@avbasov
Copy link
Contributor Author

avbasov commented Mar 12, 2019

@anacrolix Thanks for the answer. The reconnection works.

@anacrolix
Copy link
Contributor

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

3 participants