Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: decent1984 on August 03, 2021, 08:21:34 PM



Title: Remote end closed connection without response` error with bitcoinrpc.authproxy
Post by: decent1984 on August 03, 2021, 08:21:34 PM
Hi There,

I am using import bitcoinrpc.authproxy for regtest like below:

Code:
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:18444"%("bitcoin", "bitcoin"),timeout = 120)

Upon running the above code, I am getting the below http error:

Code:
 ~/Doc/code/pythonprojects  python -u "/Users/re/Documents/code/pythonprojects/mini_initial.py"
Traceback (most recent call last):
  File "/Users/re/Documents/code/pythonprojects/mini_initial.py", line 17, in <module>
    regTestChainSize = get_blockchain_size()
  File "/Users/re/Documents/code/pythonprojects/mini_initial.py", line 5, in get_blockchain_size
    iBlockSize = rpc_connection.getblockcount()
  File "/Users/re/Documents/code/pythonprojects/venv/lib/python3.9/site-packages/bitcoinrpc/authproxy.py", line 139, in __call__
    response = self._get_response()
  File "/Users/re/Documents/code/pythonprojects/venv/lib/python3.9/site-packages/bitcoinrpc/authproxy.py", line 179, in _get_response
    http_response = self.__conn.getresponse()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1349, in getresponse
    response.begin()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 285, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

We can see that there is a `Remote end closed connection without response` error, any idea what could be causing this connection issue on regtest?

Thanks


Title: Re: Remote end closed connection without response` error with bitcoinrpc.authproxy
Post by: nc50lc on August 04, 2021, 05:06:28 AM
I see that you have a reply to this thread: How to use regtest - the definitive guide (https://bitcointalk.org/index.php?topic=5268794.0)
I followed the instructions in that thread and it worked at my end.
I used your command, changed the rpc user and password then added a command and it worked.

I tried to remove some of the config and it returned with the same error when both these lines are removed:
  • connect=127.0.0.1:18444
  • rpcport=18444

I can't reproduce it by other means.

Have you included the configs that should be added to the bitcoin.conf file?
take note that it should be in the default data directory and not in the custom datadir that you've set (if you set a different one).


Title: Re: Remote end closed connection without response` error with bitcoinrpc.authproxy
Post by: achow101 on August 04, 2021, 05:10:55 AM
The default RPC port for regtest is 18443, but you are using 18444.


Title: Re: Remote end closed connection without response` error with bitcoinrpc.authproxy
Post by: nc50lc on August 04, 2021, 05:35:02 AM
The default RPC port for regtest is 18443, but you are using 18444.
Ah, that explains the error when those lines are removed from the config.
He used the command in that linked thread that uses port 18444 but didn't followed the configuration to set the port to 18444.

@decent1984 you got two options to 'fix' it:
Change your code's port to default 18443; or keep it and set 18444 in the config file as instructed in the tutorial.