HomePhabricator

zmq: enable tcp keepalive

Description

zmq: enable tcp keepalive

Summary:

These changes enable node operators to address the silent dropping (by network middle boxes) of long-lived low-activity ZMQ TCP connections via further operating system level TCP keepalive configuration. For example, ZMQ sockets that publish block hashes can be affected in this way due to the length of time it sometimes takes between finding blocks (e.g.- sometimes more than an hour).

Prior to this patch, operating system level TCP keepalive configurations would not take effect since the SO_KEEPALIVE option was not enabled on the underlying socket.

There are additional ZMQ socket options related to TCP keepalive that can be set. However, I decided not to implement those options in this changeset because doing so would require adding additional bitcoin node configuration options, and would not yield a better outcome. I preferred a small, easily reviewable patch that doesn't add a bunch of new config options, with the tradeoff that the fine tuning would have to be done via well-documented operating system specific configurations.

This is a backport of core#14687

Test Plan:

./src/qt/bitcoin-qt -regtest -txindex -zmqpubhashblock=tcp://127.0.0.1:28332 &
python3 ./contrib/zmq/zmq_sub.py
ss -panto | grep 28332 | grep ESTAB | grep bitcoin

Note: this test requires the IP address change from D10307 in zmq_sub.py

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10316

Details

Provenance
mruddy <6440430+mruddy@users.noreply.github.com>Authored on Nov 8 2018, 11:38
PiRKCommitted on Oct 13 2021, 15:40
PiRKPushed on Oct 13 2021, 15:40
Reviewer
Restricted Project
Differential Revision
D10316: zmq: enable tcp keepalive
Parents
rABCda042481290a: [Cashtab] Domain move
Branches
Unknown
Tags
Unknown

Event Timeline

PiRK committed rABCc0200506cb91: zmq: enable tcp keepalive (authored by mruddy <6440430+mruddy@users.noreply.github.com>).Oct 13 2021, 15:40