When using a python bitcoin RPC client, I sometimes encounter errors like:
>>> proxy._call("getblock", "45b0efe24da4ed0f984a8808e04b584a78cedaa8b49ac9097f724d368d0871df")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 142, in _call
'Content-type': 'application/json'})
File "/usr/lib/python3.4/http/client.py", line 1065, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1093, in _send_request
self.putrequest(method, url, **skips)
File "/usr/lib/python3.4/http/client.py", line 948, in putrequest
raise CannotSendRequest(self.__state)
http.client.CannotSendRequest: Request-sent
When this error is received, I find that:
bitcoin-cliand other RPC clients cannot get bitcoind to respond, they hang- only way to kill bitcoind is to SIGKILL it?
- RPC threads seem locked, syscalls were all waits or recvs
- on testnet in this state, bitcoind continues normal p2p gossip
Replication steps: https://gist.github.com/kanzure/57f1b50cf7fb82cc5c1a
Replication steps summary:
setgenerate true 1000- when
setgenerateis running, send another RPC request - kill the client that sent the other RPC request
- when
setgenerateis done, RPC will be unavailable - use
rpcthreads=1to help see this behavor
Expected behavior is that the RPC thread should eventually be available again.
Relevant commits: https://github.com/bitcoin/bitcoin/commit/16a5c18cea7330bd68dc9d2f768eb518af88795b https://github.com/bitcoin/bitcoin/commit/7d2cb485116636595250fce4ea4eab16a877479b
Relevant issues: #5655 (comment)
Using rpckeepalive=0 solves this problem, although the above commit messages make it sound like this is only a temporary fix. So hopefully others can replicate this problem now with the steps given above. Alternatively, #5677 should fix this too.
FWIW, I was completely unable to determine that this was a keep-alive problem when I was receiving error messages. Only once I started reading commit history on the rpcserver file did I find that rpckeepalive was meant to help with this issue. So maybe this is a docs issue.....