Bitcoin.conf file working example – Bitcoin Stack Exchange
I can’t connect to the server even after trying for several days. I’ve asked posted questions and my .conf file and my Python code, but despite this, no one has been able to tell me why it’s not connecting.
You can connect to the port using Telnet 127.0.0.1(port_num).
And I’m pretty sure I opened the port correctly. Nestats -a shows it’s open. I have both my router and firewall open for incoming and outgoing traffic. And when I remove the rule I immediately get another error saying the host refused the connection. But when I apply that rule, I get the following error instead:
(.venv) D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101>python bitcoin104.py
<bitcoinrpc.authproxy.AuthServiceProxy object at 0x0000021E5BB11730>
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 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
I’m trying to use a user’s password using rpcauth. So I have the following in my .conf file:
rpcuser=myname
rpcauth=myname:fef852a5c3e764a3a4e7fcaa283b2f1f$eadb370e8d7705d8c960570c13b49372d1a3780aa3e1ea5013908271035d4ee9
I’m not sure if this is the correct usage. I got the hash using… python ./rpcauth.py myname mypassword
I previously tried the following settings….
rpcuser=myname
rpcpassword=mypassword
What’s interesting is that sometimes, without changing anything, it connects without a response error…
for example…
PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101> python .\bitcoin104.py
>>
<bitcoinrpc.authproxy.AuthServiceProxy object at 0x000002482E142730>
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
PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101> python .\bitcoin104.py
>>
<bitcoinrpc.authproxy.AuthServiceProxy object at 0x000001F7602E2730>
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 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
I’ve searched online and there seem to be few examples of properly set up .conf files and corresponding Python rpc permission calls.
like that…
rpc_connection = AuthServiceProxy("http://%s:%(email protected):8334"%("myname","mypassword"))
best_block_hash = rpc_connection.getbestblockhash()
best_block_hash
It fails on the second line above. That is, best_block_hash = rpc_connection.getbestblockhash()
At this point I think I’ve tried everything I can think of.
My intuition is telling me that I’m probably using the user’s password incorrectly. But I tried many different configurations and many different passwords. Each time, restart node, load the changed .conf file, and rerun the Python script. And all I get is that it either times out or doesn’t respond no matter what I do now. Then, if you mess with the port, the connection will be refused with a host error instead.
What if I could see examples online of correctly set up .conf files that had the exact rpsuser and rpcpassword text and would be the same for a Python rpc socket setup? I’m not sure if I shouldn’t put “” around something, or if I should, or not. That was the problem. Or maybe I need to use rpcauth in some other way…?
Any help would be greatly appreciated… Thank you for reading this far.