-
Notifications
You must be signed in to change notification settings - Fork 478
Peers keep reconnecting every 30s #1598
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
Comments
Hi @nikumbgo12345 those folks aren't maintaining js-libp2p anymore, if you would like to take this up, please go ahead! |
thanks will do |
The connections that get closed are the circuit relay client connections. This looks like it's happening because the transport applies the hop timeout to the connection rather than the server only applying it during the initial handshake. This is with circuit relay v1, the next libp2p release will contain circuit relay v2 which has been completely rewritten, so I'd like to look at this again after the next release. |
@sneaker1 I'm not seeing this problem with circuit relay v2 (shipped with The changes I made to the repro repo to update to v2 are: diff --git a/alice.js b/alice.js
index c076d6c..ac59b73 100644
--- a/alice.js
+++ b/alice.js
@@ -6,6 +6,7 @@ import {gossipsub} from "@chainsafe/libp2p-gossipsub"
import {mplex} from "@libp2p/mplex"
import {tcp} from "@libp2p/tcp"
import {pubsubPeerDiscovery} from "@libp2p/pubsub-peer-discovery"
+import { circuitRelayTransport } from "libp2p/circuit-relay"
async function start() {
const peerId = {
@@ -26,7 +27,12 @@ async function start() {
pubsub: gossipsub({
allowPublishToZeroPeers: true,
}),
- transports: [tcp()],
+ transports: [
+ tcp(),
+ circuitRelayTransport({
+ discoverRelays: 1
+ })
+ ],
// transports: [tcp({
// outboundSocketInactivityTimeout: 0,
// inboundSocketInactivityTimeout: 0
@@ -39,15 +45,7 @@ async function start() {
pubsubPeerDiscovery({
interval: 1000,
}),
- ],
- relay: {
- // Circuit Relay options (this config is part of libp2p core configurations)
- enabled: true, // Allows you to dial and accept relayed connections. Does not make you a relay.
- autoRelay: {
- enabled: true,
- maxListeners: 2,
- },
- }
+ ]
})
let connected = false
diff --git a/bob.js b/bob.js
index a7e0e31..d2b383d 100644
--- a/bob.js
+++ b/bob.js
@@ -6,6 +6,7 @@ import {gossipsub} from "@chainsafe/libp2p-gossipsub"
import {mplex} from "@libp2p/mplex"
import {tcp} from "@libp2p/tcp"
import {pubsubPeerDiscovery} from "@libp2p/pubsub-peer-discovery"
+import { circuitRelayTransport } from "libp2p/circuit-relay"
async function start() {
const peerId = {
@@ -26,7 +27,12 @@ async function start() {
pubsub: gossipsub({
allowPublishToZeroPeers: true,
}),
- transports: [tcp()],
+ transports: [
+ tcp(),
+ circuitRelayTransport({
+ discoverRelays: 1
+ })
+ ],
// transports: [tcp({
// outboundSocketInactivityTimeout: 0,
// inboundSocketInactivityTimeout: 0
@@ -39,15 +45,7 @@ async function start() {
pubsubPeerDiscovery({
interval: 1000,
}),
- ],
- relay: {
- // Circuit Relay options (this config is part of libp2p core configurations)
- enabled: true, // Allows you to dial and accept relayed connections. Does not make you a relay.
- autoRelay: {
- enabled: true,
- maxListeners: 2,
- },
- }
+ ]
})
// Listen for new connections to peers
diff --git a/package.json b/package.json
index fe1705f..b84abb9 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,6 @@
"@libp2p/pubsub-peer-discovery": "^8.0.0",
"@libp2p/tcp": "^6.1.2",
"@libp2p/websockets": "^5.0.3",
- "libp2p": "^0.42.2"
+ "libp2p": "^0.43.4"
}
}
diff --git a/relay.js b/relay.js
index b54a9c0..1a547ea 100644
--- a/relay.js
+++ b/relay.js
@@ -7,6 +7,7 @@ import {gossipsub} from "@chainsafe/libp2p-gossipsub"
import {mplex} from "@libp2p/mplex"
import {tcp} from "@libp2p/tcp"
import {pubsubPeerDiscovery} from "@libp2p/pubsub-peer-discovery"
+import { circuitRelayServer } from "libp2p/circuit-relay"
async function start() {
const peerId = {
@@ -45,23 +46,11 @@ async function start() {
interval: 1000,
}),
],
- relay: {
- // Circuit Relay options (this config is part of libp2p core configurations)
- enabled: true, // Allows you to dial and accept relayed connections. Does not make you a relay.
- hop: {
- enabled: true, // Allows you to be a relay for other peers
- active: true, // You will attempt to dial destination peers if you are not connected to them
- },
- advertise: {
- bootDelay: 15 * 60 * 1000, // Delay before HOP relay service is advertised on the network
- enabled: true, // Allows you to disable the advertise of the Hop service
- ttl: 30 * 60 * 1000, // Delay Between HOP relay service advertisements on the network
- },
- autoRelay: {
- enabled: true, // Allows you to bind to relays with HOP enabled for improving node dialability
- maxListeners: 2, // Configure maximum number of HOP relays to use
- },
- },
+ relay: circuitRelayServer({
+ reservations: {
+ maxReservations: 2
+ }
+ })
})
// Listen for new connections to peers |
Yes, i can confirm this is now working with circuit relay v2 and libp2p version v0.43.x Thanks for your great work. |
Platform:
Linux 5.15.0-60-generic
Subsystem:
Connection Manager
Severity:
Medium
Description:
The problem described in #1513 is not solved yet.
With pubsub-peer-discovery the nodes can discover each other, but after ~30s the connection gets disconnected and shortly after reconnected.
In #1513 it was suggested to disable some tcp timeouts with
I tried that, but it is still disconnecting every 30s.
The problem also occurs when using websockets as transport.
Steps to reproduce the error:
I updated the example-repository from AlexMesser with the latest versions.
https://github.com/sneaker1/peer-reconnect-problem
Reproduction
The text was updated successfully, but these errors were encountered: