2

I have downloaded and installed and got up and running a bitcoin core node, and it is running fine as far as people are connecting to it on port 8333 just fine. However I can't seem to connect to it myself on the same machine using python bitcoinrpc library...

My .conf files looks like...

port=8333
timeout=10000
printtoconsole=1
chain=main
rpcuser=one
rpcport=8334
#rpcauth=one:xxxxxx
server=1
coinstatsindex=1
daemon=1
txindex=1

and my python app..

from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_user = "one"
rpc_password = "two"
rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8334"%("one","two"))

best_block_hash = rpc_connection.getbestblockhash()

And when it runs it fails on line

best_block_hash = rpc_connection.getbestblockhash()

with the following error...

Traceback (most recent call last):
  File ".\bitcoin104.py", line 10, in <module>
    best_block_hash = rpc_connection.getbestblockhash()
  File "D:\PROJECTS\python38_env_bitcoin\.venv\lib\site-packages\bitcoinrpc\authproxy.py", line 139, in __call__
    response = self._get_response()
  File "D:\PROJECTS\python38_env_bitcoin\.venv\lib\site-packages\bitcoinrpc\authproxy.py", line 179, in _get_response
    http_response = self.__conn.getresponse()
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py", line 1344, in getresponse
    response.begin()
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

I have checked all my ports, and I am certain they are working, they work through telnet, the netstat -a shows the ports are listening when i open the bitcoin core node, and when i try a different port I get a different error complaining about host connection was refused. So I am 99% certain the port forwarding and firewall is open to the desired ports. Port 8333 for outside connections shows a log of people connecting to the server. So I am almost certain it is not the machine, firewall, or router not allowing connections through the port.

That leaves either something I am setting up wrong with the password. I changed the setup to use a simple one, two useid and password for testing, and so I can post here to show exactly what I am doing word for word in the conf and the python script.

I am really pounding my head against the wall.. Is it possible something to do with rpcauth... i tried running that and creating a hash and then tried to use that as a replacement in my http://pass:[email protected],1:8334 connection. But it doesnt' seem to work either. But funny enough when I type the clearly wrong password in i get the same error I am getting now. But if I change say the ip address then it fails up on the AuthServiceProxy creation line instead. And the issue says that the machine host refused connection. So all this points to the node node liking my userid and/or password but I can't find any examples to know for sure I am setting these up correctly for the node in the .conf file before launching node, or if i am doing something wrong in the python script?

3
  • Is the rpcauth line actually commented out in your bitcoin.conf? Feb 1 at 6:10
  • yea, I wasn't quite sure if I needed it. I tried using it, but i am not sure exactly then what i use in the python call ie what goes in the AuthServiceProxy() initialization function? I ran the app include in bitcoin core to get that number, but I wasn't sure how I am suppose to use it. So I commented it out after using it and it didn't work. And went back to what i have seen in the very few case examples I could find, which didn't seem to include it.. Feb 1 at 16:45
  • In your bitcoin.conf file, there should be, uncommented an rpcuser= and rpcpassword= pair of lines. Alternatively, you can have an rpcauth= line which specifies username and password together, salted (for more info see github.com/jlopp/bitcoin-core-rpc-auth-generator). But if you don't have either one or the other, then you haven't really specified a username and password pair, so you can't authenticate.
    – alexg
    Feb 6 at 18:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.