janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.57k stars 1.18k forks source link

FIXED: btcexp:error Error RpcError-002: Error: socket hang up, json: {"code":"ECONNRESET","userData" .... #678

Closed filipponeri closed 2 weeks ago

filipponeri commented 3 weeks ago

Hi, I cannot connect to bitcoin core receiving an RPC error ECONNRESET. I am still downloading the blockchain and yesterday btc-rpc-explorer was working. Until yesterday I was receiving the socket hang up, ECONNRESET error 30% of the times I was connecting to bitcoind. Today it is not working at all. If it were related to timing, any idea how to extend the wait time to establish a connection? Anyone has any idea how to solve this issue? Thanks, Filippo


btc-rpc-explorer file .env

BTCEXP_DEMO=false # enables some demo/informational aspects of the site BTCEXP_NO_RATES=false # enables querying of exchange rate data BTCEXP_SLOW_DEVICE_MODE=false # enables resource-intensive tasks (UTXO set query, 24hr volume querying) that are inappropriate for "slow" devices BTCEXP_ADDRESS_API=electrum BTCEXP_ELECTRUM_SERVERS=ssl://electrum.coinucopia.io:50002


Terminal output

btc-rpc-explorer --port 8080 --bitcoind-cookie /media/neri/Elements/bitcoin-blockdata/.cookie btcexp:app Searching for config files... +0ms btcexp:app Config file not found at /home/neri/.config/btc-rpc-explorer.env, continuing... +2ms btcexp:app Config file not found at /etc/btc-rpc-explorer/.env, continuing... +0ms btcexp:app Config file found at /home/neri/Documents/btc-rpc-explorer-3.4.0/.env, loading... +0ms btcexp:app Default cacheId '3.4.0' +2s btcexp:app Enabling view caching (performance will be improved but template edits will not be reflected) +36ms btcexp:app Session config: {"secret":"","resave":false,"saveUninitialized":true,"cookie":{"secure":false}} +14ms btcexp:app Environment(development) - Node: v18.19.1, Platform: linux, Versions: {"node":"18.19.1","acorn":"8.8.1","ada":"2.7.2","ares":"1.27.0","base64":"0.5.0","brotli":"1.1.0","cjs_module_lexer":"1.2.3","cldr":"44.1","icu":"74.2","llhttp":"6.1.0","modules":"109","napi":"9","nghttp2":"1.59.0","openssl":"3.0.13","simdutf":"3.2.18","tz":"2023c","unicode":"15.1","uv":"1.48.0","uvwasi":"0.0.19","v8":"10.2.154.26-node.28","zlib":"1.3"} +13ms btcexp:app No sourcecode version available, continuing to use default cacheId '3.4.0' +0ms btcexp:app Starting BTC RPC Explorer, v3.4.0 at http://127.0.0.1:8080/ +0ms btcexp:app RPC Credentials: { btcexp:app "host": "127.0.0.1", btcexp:app "port": 8332, btcexp:app "authType": "cookie", btcexp:app "username": "cookie", btcexp:app "password": "", btcexp:app "authCookieFilepath": "/media/neri/Elements/bitcoin-blockdata/.cookie", btcexp:app "timeout": 5000 btcexp:app } +1ms btcexp:app Connecting to RPC node at [127.0.0.1]:8332 +0ms btcexp:app RPC Connection properties: { btcexp:app "host": "127.0.0.1", btcexp:app "port": 8332, btcexp:app "username": "cookie", btcexp:app "password": "*****", btcexp:app "timeout": 5000 btcexp:app } +1ms btcexp:app RPC authentication is cookie based; watching for changes to the auth cookie file... +0ms btcexp:app Verifying RPC connection... +1ms btcexp:app Loading mining pools config +62ms btcexp:app RPC Connected: version=270000 subversion=/Satoshi:27.0.0/, parsedVersion(used for RPC versioning)=27.0.0, protocolversion=70016, chain=main, services=[NETWORK, WITNESS, NETWORK_LIMITED, P2P_V2] +474ms btcexp:app Loading historical data for chain=main +0ms btcexp:app Loading holiday data +0ms btcexp:app txindex check: trying getindexinfo +18ms btcexp:app txindex check: getindexinfo={"txindex":{"synced":false,"best_block_height":362074}} +839ms btcexp:app txindex check: available! +0ms btcexp:error Error RpcError-002: Error: socket hang up, json: {"code":"ECONNRESET","userData":{"request":{"method":"getblockstats","parameters":[513821]}}}, userData: [object Object] (json: {"request":"getblockstats([513821])"}) +0ms btcexp:errorVerbose Stack: Error: socket hang up btcexp:errorVerbose at connResetException (node:internal/errors:720:14) btcexp:errorVerbose at Socket.socketCloseListener (node:_http_client:474:25) btcexp:errorVerbose at Socket.emit (node:events:529:35) btcexp:errorVerbose at TCP. (node:net:351:12) +0ms Error: socket hang up at connResetException (node:internal/errors:720:14) at Socket.socketCloseListener (node:_http_client:474:25) at Socket.emit (node:events:529:35) at TCP. (node:net:351:12)

Benjade commented 2 weeks ago

Check that the path to the .cookie file (/media/neri/Elements/bitcoin-blockdata/.cookie) is readable by the user. Try setting a longer time limit and limit intensive requests btc-rpc-explorer --port 8080 --bitcoind-cookie /media/neri/Elements/bitcoin-blockdata/.cookie --timeout=15000 BTCEXP_NO_SLOW_SYNC=true Restart the Bitcoin node Restart btc-rpc-explorer Check logs ~/.bitcoin/debug.log

filipponeri commented 2 weeks ago

FIXED: Thank you @Benjade for the reply. After several tentatives, I managed to have the explorer work by doing the following: 1) switched from bitcoin core to bitcoin knots 2) reindex the blockchain 3) modified the .env file as follow:

BTCEXP_DEMO=false # enables some demo/informational aspects of the site BTCEXP_NO_RATES=false # enables querying of exchange rate data BTCEXP_SLOW_DEVICE_MODE=false # enables resource-intensive tasks (UTXO set query, 24hr v olume querying) that are inappropriate for "slow" devices BTCEXP_ADDRESS_API=electrum BTCEXP_ELECTRUM_SERVERS=ssl://electrum.coinucopia.io:50002 BTCEXP_BASIC_AUTH_USER=cookie BTCEXP_BASIC_AUTH_PASSWORD=d16f5adb2695e5d330bc14b51e44dXXXXXXXXXXXXXXXXXXXXXXXXX f