Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket.timeout: timed out #33

Open
robertsdotpm opened this issue May 22, 2014 · 6 comments
Open

socket.timeout: timed out #33

robertsdotpm opened this issue May 22, 2014 · 6 comments

Comments

@robertsdotpm
Copy link

Under Python 3.3, Ubuntu 14.04 I use the following code:
from bitcoinrpc.authproxy import AuthServiceProxy
x = AuthServiceProxy("....")
x.rpc_calls(...)

The Bitcoin RPC version I'm using is from the latest master branch.

Anyway, here is my observation: After making at least one successful RPC call the library will randomly throw a timeout exception that looks like this:
Original exception was:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.3/dist-packages/bitcoinrpc/authproxy.py", line 116, in call
response = self._get_response()
File "/usr/local/lib/python3.3/dist-packages/bitcoinrpc/authproxy.py", line 138, in _get_response
http_response = self.__conn.getresponse()
File "/usr/lib/python3.3/http/client.py", line 1147, in getresponse
response.begin()
File "/usr/lib/python3.3/http/client.py", line 358, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.3/http/client.py", line 320, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.3/socket.py", line 297, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

I'm just wondering what the reason is for the timeout. It seems my Bitcoind daemon is never actually down. After the timeout occurs I can't issue any more RPC commands without the same exception but if I immediately reconnect with x = AuthServiceProxy("....") and issue the same failed RPC call it ends up working.

An obvious fix is to use a wrapper, but I'm wondering if it's a problem with this library or what reasons there are for this error.

I have confirmed the bug exists under multiple Python versions and multiple coind versions (hosted locally and remotely.) The RPC connection doesn't necessarily need to be open for a long time before the timeout occurs and there doesn't seem to be any pattern to the error.

@robertsdotpm
Copy link
Author

Unless it really is that the connection has been open too long. I haven't exactly tried to time things.

@ShawnKimble
Copy link

I see the same error, Ubuntu 15.10, Python 2.7

Might be related to #txns in memory on the node, causing low memory condition. I feel core doesn't handle memory efficiently.

@dzimbeck
Copy link

Redefining Authserviceproxy doesn't work for me. This issue is really driving me crazy.

@dzimbeck
Copy link

Okay so if it fails you can reboot the daemon and then like robertsdotpm said and then you say like:
Proxy = AuthServiceProxy(url)
Then you need to repeat this EVERY time you fail. A single failure will throw it off forever until its called again at least in my experience. Would be nice to see this bug resolved. This is the only workaround I've come up with

@mooncoindev
Copy link

mooncoindev commented Feb 3, 2017

@dzimbeck Restarting the daemon is a time/memory expensive way to get around the problem. Instead if you structure your python script to 'fall through' and exit after a set of RPC commands is executed; you can simply set your python to be continually re-executed in a small looping bash script. This way you get around the issue where redefining AuthServiceProxy doesn't wake the connection back up.
I don't believe it is the daemon.
Check the moonaudit script in my repo.

@dzimbeck
Copy link

dzimbeck commented Feb 3, 2017

Thanks yeah I see that I can just try catch and then when it gets disconnected, just redeclare the authproxy. If that doesn't fire it back up your solution works. You are right, no need to restart the daemon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants