Page MenuHomePhabricator

zmq: enable tcp keepalive

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


Group Reviewers
Restricted Project
rABCc0200506cb91: zmq: enable tcp keepalive

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:// &
python3 ./contrib/zmq/
ss -panto | grep 28332 | grep ESTAB | grep bitcoin

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

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable