Reduce dial timeout to 10 seconds (#325)

This commit is contained in:
prathamesh0 2023-02-17 18:39:47 +05:30 committed by GitHub
parent a56ade96fa
commit d50d78ed17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -30,7 +30,7 @@ export const CONN_CHECK_INTERVAL = 10000; // 10 seconds
export const PING_TIMEOUT = 5000; // 5 seconds
// Delay time in ms to redial relay node on failing to connect
export const RELAY_REDIAL_DELAY = 5000; // 5 sconds
export const RELAY_REDIAL_DELAY = 5000; // 5 seconds
// Max number of relay node connections for a peer after which it starts igoring them
export const DEFAULT_MAX_RELAY_CONNECTIONS = 2;
@ -52,3 +52,6 @@ export const MAX_CONNECTIONS = 10;
// Min number of connections for a peer below which autodial triggers (if enabled)
export const MIN_CONNECTIONS = 0;
// How long a dial is allowed to take before it's aborted
export const DIAL_TIMEOUT = 10000; // 10 seconds

View File

@ -27,7 +27,18 @@ import { multiaddr, Multiaddr } from '@multiformats/multiaddr';
import { floodsub } from '@libp2p/floodsub';
import { pubsubPeerDiscovery } from '@libp2p/pubsub-peer-discovery';
import { MAX_CONCURRENT_DIALS_PER_PEER, MAX_CONNECTIONS, MIN_CONNECTIONS, PUBSUB_DISCOVERY_INTERVAL, PUBSUB_SIGNATURE_POLICY, RELAY_TAG, RELAY_REDIAL_DELAY, PING_TIMEOUT, DEFAULT_MAX_RELAY_CONNECTIONS } from './constants.js';
import {
MAX_CONCURRENT_DIALS_PER_PEER,
MAX_CONNECTIONS,
MIN_CONNECTIONS,
DIAL_TIMEOUT,
PUBSUB_DISCOVERY_INTERVAL,
PUBSUB_SIGNATURE_POLICY,
RELAY_TAG,
RELAY_REDIAL_DELAY,
DEFAULT_MAX_RELAY_CONNECTIONS,
PING_TIMEOUT
} from './constants.js';
import { PeerHearbeatChecker } from './peer-heartbeat-checker.js';
import { dialWithRetry } from './utils/index.js';
@ -119,6 +130,7 @@ export class Peer {
autoDial: false,
maxConnections: MAX_CONNECTIONS,
minConnections: MIN_CONNECTIONS,
dialTimeout: DIAL_TIMEOUT,
keepMultipleConnections: true // Set true to get connections with multiple multiaddr
},
ping: {