0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-05 10:17:30 -05:00
bitcoin-bitcoin-core/src/zmq
Jonas Schnelli 3a3e21dafb
Merge #14687: zmq: enable tcp keepalive
c276df7759 zmq: enable tcp keepalive (mruddy)

Pull request description:

  This addresses https://github.com/bitcoin/bitcoin/issues/12754.

  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.

  I tested this patch by running a node with:
  `./src/qt/bitcoin-qt -regtest -txindex -datadir=/tmp/node -zmqpubhashblock=tcp://127.0.0.1:28332 &`
  and connecting to it with:
  `python3 ./contrib/zmq/zmq_sub.py`

  Without these changes, `ss -panto | grep 28332 | grep ESTAB | grep bitcoin` will report no keepalive timer information. With these changes, the output from the prior command will show keepalive timer information consistent with the configuration at the time of connection establishment, e.g.-: `timer:(keepalive,119min,0)`.

  I also tested with a non-TCP transport and did not witness any adverse effects:
  `./src/qt/bitcoin-qt -regtest -txindex -datadir=/tmp/node -zmqpubhashblock=ipc:///tmp/bitcoin.block &`

ACKs for top commit:
  adamjonas:
    Just to summarize for those looking to review - as of c276df7759 there are 3 tACKs (n-thumann, Haaroon, and dlogemann), 1 "looks good to me" (laanwj) with no NACKs or any show-stopping concerns raised.
  jonasschnelli:
    utACK c276df7759

Tree-SHA512: b884c2c9814e97e666546a7188c48f9de9541499a11a934bd48dd16169a900c900fa519feb3b1cb7e9915fc7539aac2829c7806b5937b4e1409b4805f3ef6cd1
2020-09-02 09:09:18 +02:00
..
zmqabstractnotifier.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
zmqabstractnotifier.h ZMQ: add options to configure outbound message high water mark, aka SNDHWM 2018-10-19 07:36:13 -04:00
zmqconfig.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
zmqnotificationinterface.cpp [validation interface] Remove vtxConflicted from BlockConnected 2020-03-11 18:38:33 -04:00
zmqnotificationinterface.h [validation interface] Remove vtxConflicted from BlockConnected 2020-03-11 18:38:33 -04:00
zmqpublishnotifier.cpp Merge #14687: zmq: enable tcp keepalive 2020-09-02 09:09:18 +02:00
zmqpublishnotifier.h ZMQ: add options to configure outbound message high water mark, aka SNDHWM 2018-10-19 07:36:13 -04:00
zmqrpc.cpp rpc: Assert that RPCArg names are equal to CRPCCommand ones (zmq) 2020-08-14 12:37:51 +02:00
zmqrpc.h RPC: Add new getzmqnotifications method. 2018-07-05 08:02:22 +02:00