Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: NotATether on November 24, 2020, 01:50:16 PM



Title: What is the default inbound and outbound connection timeout?
Post by: NotATether on November 24, 2020, 01:50:16 PM
By now, my full node has about 90 incoming connections and 10 outgoing connections. The server I host my node on had a firewall issue recently that caused all network packets to be dropped, a problem I fixed in a few minutes without rebooting or otherwise exiting Core. My peers have stayed largely the same and it doesn't look like any disconnected from a timeout.

So, I would like to know what is the default timeout for inbound connections and outbound connections before the other peer closes the connection. In other words, how much time I have to fix network connectivity issues before I begin to lose most of my peers. I assume these two can have different values?


Title: Re: What is the default inbound and outbound connection timeout?
Post by: ranochigo on November 24, 2020, 02:04:46 PM
So, I would like to know what is the default timeout for inbound connections and outbound connections before the other peer closes the connection. In other words, how much time I have to fix network connectivity issues before I begin to lose most of my peers. I assume these two can have different values?
Bitcoin Core has two flags, -peertimeout[1] and -timeout[2]. Both of which are configurable by the user. The latter meaning the timeout when connecting to peers while the former means the time for which it waits when a peer is unresponsive before disconnecting.

I don't think Bitcoin Core removes the nodes from peers.dat unless they misbehave right? If so, then your peers will reconnect when they restart anyways so no worries there.

You can find the relevant codes here:
[1] https://github.com/bitcoin/bitcoin/blob/1b75f2542d154ba6f9f75bc2c9d7a0ca54de784c/src/net.h#L85
[2] https://github.com/bitcoin/bitcoin/blob/1ae46dce60a187740ec78b5a3cee8baad0fa539d/src/netbase.h#L23


Title: Re: What is the default inbound and outbound connection timeout?
Post by: jackg on November 24, 2020, 02:05:27 PM
From what I know the peers.dat file contains 1000 peers (by default) that your node can connect to. I dont think such time exists I think you might just drop in the rankings of some nodes (if they're favouring faster ping speeds first) but you won't be completely removed from the peers.dat until the node receives peers that are more favourable than you - and once your dropped if your connection is fast enough and you're fully synced your address will probably be propagated again quite fast.


Title: Re: What is the default inbound and outbound connection timeout?
Post by: ABCbits on November 25, 2020, 09:31:50 AM
OP, if you need default parameter of Bitcoin Core, you can check https://jlopp.github.io/bitcoin-core-config-generator/ (https://jlopp.github.io/bitcoin-core-config-generator/) which shows default parameter with short explanation for each group with.

I don't think Bitcoin Core removes the nodes from peers.dat unless they misbehave right? If so, then your peers will reconnect when they restart anyways so no worries there.

I agree, i doubt sending few incomplete transaction/block is enough to get you banned. But even if OP node is banned, usually it's temporary (default is 86400 sec/1 day) and will be added to peers.dat after short time.