I am using a small script and get a timeout from python. This is my script:
import bitcoin
import bitcoin.rpc
from bitcoin.rpc import RawProxy
p = RawProxy()
hash = '0000000000000001b6b9a13b095e96db41c4a928b97ef2d944a9b31b2cc7bdc4'
infoblock = p.getblock(hash)
print(infoblock['difficulty'])
This is my error:
bitcoin@raspberrypi ~/.bitcoin/BuchSkripte $ python3 49_rpc_example.py
Traceback (most recent call last):
File "49_rpc_example.py", line 11, in <module>
infoblock = p.getblock(hash)
File "/usr/local/lib/python3.5/dist-packages/bitcoin/rpc.py", line 306, in <lambda>
f = lambda *args: self._call(name, *args)
File "/usr/local/lib/python3.5/dist-packages/bitcoin/rpc.py", line 236, in _call
response = self._get_response()
File "/usr/local/lib/python3.5/dist-packages/bitcoin/rpc.py", line 261, in _get_response
http_response = self.__conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.5/socket.py", line 576, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
When using the same method getblock
via bitcoin-cli
it takes 120 seconds to finish on my Raspberry. If the timeout is related to this duration, can I increase it in the script?
I read that the socket timeout can be set but I wonder if I can do this if I use a library for the connection.