spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.49k stars 3.1k forks source link

Cannot open two wallets after JSONRPC change #1571

Closed kyuupichan closed 8 years ago

kyuupichan commented 8 years ago

It seems recent daemon changes have an issue. When opening the 2nd wallet I get:

Traceback (most recent call last): File "./electrum", line 355, in daemon = Daemon(config, network, gui) File "/home/neil/src/electrum/lib/daemon.py", line 72, in init self.server = SimpleJSONRPCServer((host, port), requestHandler=RequestHandler, logRequests=False) File "/usr/local/lib/python2.7/site-packages/jsonrpclib/SimpleJSONRPCServer.py", line 211, in init bind_and_activate) File "/usr/local/lib/python2.7/SocketServer.py", line 420, in init self.server_bind() File "/usr/local/lib/python2.7/SocketServer.py", line 434, in server_bind self.socket.bind(self.server_address) File "/usr/local/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 48] Address already in use

ecdsa commented 8 years ago

try to remove the try..except block in get_daemon, after you have launched the first wallet

kyuupichan commented 8 years ago

Is this helpful?

Traceback (most recent call last): File "./electrum", line 327, in server = get_daemon(config) File "/home/neil/src/electrum/lib/daemon.py", line 37, in get_daemon server.ping() File "/usr/local/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 276, in call return self.send(self.name, kwargs) File "/usr/local/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 224, in _request response = self._run_request(request) File "/usr/local/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 242, in _run_request verbose=self.__verbose File "/usr/local/lib/python2.7/xmlrpclib.py", line 1280, in request return self.single_request(host, handler, request_body, verbose) File "/usr/local/lib/python2.7/xmlrpclib.py", line 1328, in single_request response.msg, xmlrpclib.ProtocolError: <ProtocolError for localhost:7777: 500 Internal Server Error>

ecdsa commented 8 years ago

it looks like the jsonrpc lib is not working properly on your system. I guess that all daemon commands are broken for you as well

ecdsa commented 8 years ago

can you test if that works for you: https://docs.python.org/2/library/simplexmlrpcserver.html#simplexmlrpcserver-example

kyuupichan commented 8 years ago

Yes it seems to work fine. Server output after many invocations:

neil@zotac:~$ python2.7 /tmp/server.py 127.0.0.1 - - [05/Dec/2015 20:12:04] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:04] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:04] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:04] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:19] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:19] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:19] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:19] "POST /RPC2 HTTP/1.1" 200 - 127.0.0.1 - - [05/Dec/2015 20:12:20] "POST /RPC2 HTTP/1.1" 200 -

Client output from 2 invocations:

neil@zotac:~$ python2.7 /tmp/client.py 8 5 2 ['add', 'div', 'pow', 'system.listMethods', 'system.methodHelp', 'system.methodSignature'] neil@zotac:~$ neil@zotac:~$ python2.7 /tmp/client.py 8 5 2 ['add', 'div', 'pow', 'system.listMethods', 'system.methodHelp', 'system.methodSignature']

kyuupichan commented 8 years ago

This is the problematic line:

self.server.socket.settimeout(1)

Without that line it works. Why do we need to set a timeout?

kyuupichan commented 8 years ago

Since interface.py sets socket timeouts without issue, albeit whilst directly controlling the sockets itself, I can only think this is something about the way the JSON server works, or a difference between our Python versions.

kyuupichan commented 8 years ago

Fixed with 03b4868bf84340ba0d5c847e3eec07b227f123d6. ThomasV confirmed working for him too.