Using bitcoinrpc python wrapper returns httplib.BadStatusLine: ''

0 votes

Hey,

So I'm using Garzik's python wrapper (https://github.com/jgarzik/python-bitcoinrpc) to call the rpc service and talk to the network (from localhost). 

rpcUser 'multichainrpc'

rpcHost '127.0.0.1'

rpcPort '7343'

 

And I'm getting the following error:

  File "/usr/lib/python2.7/httplib.py", line 1073, in getresponse

    response.begin()

  File "/usr/lib/python2.7/httplib.py", line 415, in begin

    version, status, reason = self._read_status()

  File "/usr/lib/python2.7/httplib.py", line 379, in _read_status

    raise BadStatusLine(line)

httplib.BadStatusLine: ''

 

I will further investigate what's wrong, but I wanted to ask if anyone has already encountered this problem or used this wrapper to talk to multichain.

 

asked Jan 21, 2016 by Nico

1 Answer

0 votes
UPDATE

Fixed the library problem. Two things where happening:

1- The rpc-api-call was calling the wrong port. Multichain uses 2 ports; "default-network-port" : 7343 and "default-rpc-port" : 7342. We were calling the network and not the rpc port.

2-Bitcoinrpc's issue #62 (https://github.com/jgarzik/python-bitcoinrpc/issues/62). The call using AuthServiceProxy was returning None because the library is not up-to-date on pip and #62's fix was commited and merged to github but not pushed to the pip repo.

Calls work now! I fixed it by uninstalling pip's package and installing it from github

sudo pip install -e git+https://github.com/jgarzik/python-bitcoinrpc.git#egg=hyde

>>> service_url = 'http://%s:%s@%s:%s'%(rpcUser,rpcPassword,rpcHost,rpcPort)
>>> rpc = AuthServiceProxy(service_url)
>>> rpc.getinfo()
{u'connections': 1, u'setupblocks': 60, u'errors': u'', u'protocol': u'multichain', u'description': u'MultiChain chain1', u'paytxfee': Decimal('0E-8'), u'keypoololdest': 12323234, u'keypoolsize': 5, u'relayfee': Decimal('0E-8'), u'nodeaddress': u'swisschain@rpcHost:rpcPort', u'walletversion': 60000, u'difficulty': Decimal('0.00008774'), u'testnet': False, u'version': u'1.0 alpha 15', u'proxy': u'', u'protocolversion': 10003, u'timeoffset': 0, u'blocks': 44020, u'balance': Decimal('0.00650000'), u'port': 7343, u'chainname': u'chain1'}
answered Jan 21, 2016 by nicosandller
Great - thanks for answering your own question!
No probs! I wasn't logged in when asking the question and I then found a solution! Sorry for that!
...