Example working bitcoin.conf file – Bitcoin Stack Exchange

[ad_1]

I am unable to connect to my server despite trying for days. I have asked posted questions and my .conf file and my python code and despite this no one has been able to give me a reason why it is not connecting.

I am able to connect to the port using telnet 127.0.0.1 [port_num]

And I am decently sure I have opened the ports correctly. Nestats -a shows them open. I have opened them both for incoming and outgoing, both for my router, and for my firewall. And when I remove the rules, I immediately get a different error stating the host refused connections. But when i have those rules engaged I instead get the following error…

(.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 am trying use use the user password using rpcauth.. so in my .conf file I have something like…

rpcuser=myname
rpcauth=myname:fef852a5c3e764a3a4e7fcaa283b2f1f$eadb370e8d7705d8c960570c13b49372d1a3780aa3e1ea5013908271035d4ee9

I am not sure if this is the proper usage.
I got the hash using…
python ./rpcauth.py myname mypassword

I previous tried a setup like….

rpcuser=myname
rpcpassword=mypassword

What is interesting it I also sometimes get a connection without response error as well without having changed anything…

For instance…

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 have searched online and there is very little it seems in terms of examples of a properly setup .conf file and corresponding python rpc authority call…

Like so…

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, ie best_block_hash = rpc_connection.getbestblockhash()

At this point I think i have tried everything I can possible think of.

My gut is saying it is something I might be doing wrong with the user password perhaps. But I have tried many different configurations, many different passwords. Restarting the node each time and loading in the changed .conf file, and running the python script again.
And all I get is the timed out, or no response no matter what i do now..
Then if I mess with the port it I get the connection refused by host error instead.

If I could maybe see an example online of a properly setup .conf file with the exact rpsuser and rpcpassword text, and the same in the python rpc socket setup. I have no idea if maybe I shouldn’t be putting “” around something, or should be and I am not, and that has been the issue. Or perhaps I need to be using the rpcauth in a different way…?

Any help would be greatly greatly appreciated…
Thanks for reading this far regardless.

[ad_2]

Source link


Posted

in

by

Tags:

Comments

Leave a Reply

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