Page MenuHomePhabricator

zmq: enable tcp keepalive
ClosedPublic

Authored by PiRK on Oct 12 2021, 15:30.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCc0200506cb91: 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