jgarzik/python-bitcoinrpc

BrokenPipeError: [Errno 32] Broken pipe

Opened this issue · 1 comments

Trying to create a raw transaction on the testnet gives the following error:

  File "<pyshell#11>", line 1, in <module>
    con.createrawtransaction([{"txid":"a8fd2dacb674cec804e1cd861c9310d999d6d149fd17d5e44034ed1207860f60","vout":0}], {"myJXY5WznWSLqSoghhieCXfykkZnCz9P1U":1.79})
  File "/usr/local/lib/python3.5/dist-packages/bitcoinrpc/authproxy.py", line 136, in __call__
    'Content-type': 'application/json'})
  File "/usr/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 936, in _send_output
    self.send(message_body)
  File "/usr/lib/python3.5/http/client.py", line 908, in send
    self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe
>>> 

I believe the Broken pipe happens if you are typing commands from a python console and you wait too long between requests. I had this error but resolved it by not lingering between requests and also by adding the timeout arg as suggested in the Readme.rst:
Socket timeouts under heavy load
Pass the timeout argument to prevent "socket timed out" exceptions:
rpc_connection = AuthServiceProxy(
"http://%s:%s@%s:%s"%(rpc_user, rpc_password, rpc_host, rpc_port), timeout=120)

If the Broken pipe error still occurs then perhaps some sort of Keep Alive (do nothing) request should be sent at rapid intervals to keep the Pipe from closing. Or else trap the Broken pipe exception and make a new connection.