json rpc – bitcoin core node won’t allow me to request commands


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…


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
  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?


Source link






Leave a Reply

Your email address will not be published. Required fields are marked *