-
Notifications
You must be signed in to change notification settings - Fork 479
Peer keeps reconnecting every ~30 seconds. #1513
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
Could you provide a runnable example that shows the problem? It would help me get to the bottom of the issue. |
@achingbrain sure, here it is |
Same problem !! |
Same problem with libp2p 0.40.1. Code: import { createLibp2p } from 'libp2p'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { noise } from '@chainsafe/libp2p-noise'
import { kadDHT } from '@libp2p/kad-dht'
import last from 'it-last'
import delay from 'delay'
import drain from 'it-drain'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
const createNode = async () => {
const node = await createLibp2p({
addresses: {
listen: ['/ip4/0.0.0.0/tcp/0']
},
transports: [tcp()],
streamMuxers: [mplex()],
connectionEncryption: [noise()],
dht: kadDHT()
})
node.connectionManager.addEventListener("peer:connect", (evt) => {
const connection = evt.detail;
console.log("Connection established to:", connection.remotePeer.toString()); // Emitted when a peer has been found
});
node.connectionManager.addEventListener("peer:disconnect", (evt) => {
const connection = evt.detail;
console.log("Connection disconnected:", connection.remotePeer.toString()); // Emitted when a peer has been found
});
node.addEventListener("peer:discovery", (evt) => {
const peer = evt.detail;
// No need to dial, autoDial is on
console.log("Discovered:", peer.id.toString());
});
await node.start()
return node
}
;(async () => {
const [node1, node2, node3] = await Promise.all([
createNode(),
createNode(),
createNode()
])
await node1.peerStore.addressBook.set(node2.peerId, node2.getMultiaddrs())
await node2.peerStore.addressBook.set(node3.peerId, node3.getMultiaddrs())
await Promise.all([
node1.dial(node2.peerId),
node2.dial(node3.peerId)
])
})(); Output:
|
It seems that the issue is on libp2p-tcp package. transports: [tcp({
outboundSocketInactivityTimeout: 0,
inboundSocketInactivityTimeout: 0
})] It disabling the timeout safe? |
If the default in node is to not have a timeout, then maybe? It's possible the default timeout is too short - the solution might be to have no timeout by default (e.g the same as node) and let people configure it if they need it. Please can you open an issue against libp2p/js-libp2p-tcp to discuss this? Closing as the solution is to disable the timeout. |
I am having the same issue. |
Severity: Medium
Description:
I have two peers connected to the same relay server. Peers successfully connect to each other, but keep reconnecting every ~30 seconds being unreachable for 80-100ms. Since we are heavily using pubsub in our app, this behavior leads to missing pubsub messages in this reconnection intervals.
I put some logs on
connect/disconnect
events on both peers:Relay logs:
Peer A:
---------------------------------------------- PeerId: 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 Listening on: [ '/ip4/127.0.0.1/tcp/5001/p2p/12D3KooWNvSZnPi3RrhrTwEY4LuuBeB6K6facKUCJcyWG1aoDd2p/p2p-circuit/p2p/12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9' ] ---------------------------------------------- Connected to 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF Disconnected from 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF disconnected after: 29.925s Connected to 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF reconnected after: 99.658ms Disconnected from 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF disconnected after: 29.954s Connected to 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF reconnected after: 89.978ms Disconnected from 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF disconnected after: 29.968s Connected to 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF reconnected after: 85.511ms Disconnected from 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF disconnected after: 29.963s
Peer B:
---------------------------------------------- PeerId: 12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF Listening on: [ '/ip4/127.0.0.1/tcp/5001/p2p/12D3KooWNvSZnPi3RrhrTwEY4LuuBeB6K6facKUCJcyWG1aoDd2p/p2p-circuit/p2p/12D3KooWFYyvJysHGbbYiruVY8bgjKn7sYN9axgbnMxrWVkGXABF' ] ---------------------------------------------- Connected to 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 Disconnected from 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 reconnected after: 29.937s Connected to 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 unavailable for: 127.696ms Disconnected from 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 reconnected after: 29.960s Connected to 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 unavailable for: 89.762ms Disconnected from 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 reconnected after: 29.967s Connected to 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 unavailable for: 78.319ms Disconnected from 12D3KooWLV3w42LqUb9MWE7oTzG7vwaFjPw9GvDqmsuDif5chTn9 reconnected after: 29.969s
I tested the same behavior on go-libp2p nodes and there were no reconnects during the node lifecycle.
Is this a bug or by design or is it configurable somehow?
The text was updated successfully, but these errors were encountered: