janoside / btc-rpc-explorer

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

Error RpcError-001: Error: ESOCKETTIMEDOUT, json: {"code":"ESOCKETTIMEDOUT","connect":false,"userData":{"request":"getblockchaininfo"}}, userData: [object Object] (json: {"request":"getblockchaininfo"}) #427

Closed oscarmike556 closed 1 year ago

oscarmike556 commented 2 years ago

I am getting this bug:

Error RpcError-001: Error: ESOCKETTIMEDOUT, json: {"code":"ESOCKETTIMEDOUT","connect":false,"userData":{"request":"getblockchaininfo"}}, userData: [object Object] (json: {"request":"getblockchaininfo"})

btc-rpc-explorer was working fine and then suddenly failed.

To Reproduce

Steps to reproduce the behavior:

  1. install bitcoin core
  2. install node.js
  3. sync node
  4. Around August 2019 is when btc-rpc-explorer fails. Up until around that date, the Explorer loads just fine at the instance of synchronization.

the full log when I start btc-rpc-explorer:

btcexp:app Searching for config files... +0ms
  btcexp:app Config file found at /home/nomad/.config/btc-rpc-explorer.env, loading... +1ms
  btcexp:app Config file not found at /etc/btc-rpc-explorer/.env, continuing... +0ms
  btcexp:app Config file not found at /home/nomad/.env, continuing... +2ms
Loading RPC cookie file: /media/sf_B_DRIVE/.bitcoin/.cookie
  btcexp:app Default cacheId '3.3.0' +646ms
  btcexp:app Enabling view caching (performance will be improved but template edits will not be reflected) +12ms
  btcexp:app Environment(development) - Node: v16.14.1, Platform: linux, Versions: {"node":"16.14.1","v8":"9.4.146.24-node.20","uv":"1.43.0","zlib":"1.2.11","brotli":"1.0.9","ares":"1.18.1","modules":"93","nghttp2":"1.45.1","napi":"8","llhttp":"6.0.4","openssl":"1.1.1m+quic","cldr":"40.0","icu":"70.1","tz":"2021a3","unicode":"14.0","ngtcp2":"0.1.0-DEV","nghttp3":"0.1.0-DEV"} +4ms
  btcexp:app No sourcecode version available, continuing to use default cacheId '3.3.0' +0ms
  btcexp:app Starting BTC RPC Explorer, v3.3.0 at http://0.0.0.0:3002/ +0ms
  btcexp:app Connecting to RPC node at 127.0.0.1:8332 +1ms
  btcexp:app Verifying RPC connection... +3ms
  btcexp:app Loading mining pools config +0ms
  btcexp:error Error RpcError-001: Error: ESOCKETTIMEDOUT, json: {"code":"ESOCKETTIMEDOUT","connect":false,"userData":{"request":"getnetworkinfo"}}, userData: [object Object] (json: {"request":"getnetworkinfo"}) +0ms
  btcexp:errorVerbose Stack: Error: ESOCKETTIMEDOUT
  btcexp:errorVerbose     at ClientRequest.<anonymous> (/usr/lib/node_modules/btc-rpc-explorer/node_modules/request/request.js:816:19)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at ClientRequest.emit (node:events:526:28)
  btcexp:errorVerbose     at Socket.emitRequestTimeout (node:_http_client:758:9)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at Socket.emit (node:events:538:35)
  btcexp:errorVerbose     at Socket._onTimeout (node:net:501:8)
  btcexp:errorVerbose     at listOnTimeout (node:internal/timers:559:17)
  btcexp:errorVerbose     at processTimers (node:internal/timers:502:7) +0ms
  btcexp:error Error 32ugegdfsde: Error: ESOCKETTIMEDOUT, json: {"code":"ESOCKETTIMEDOUT","connect":false,"userData":{"request":"getnetworkinfo"}}, userData: [object Object] (json: {}) +1ms
  btcexp:errorVerbose Stack: Error: ESOCKETTIMEDOUT
  btcexp:errorVerbose     at ClientRequest.<anonymous> (/usr/lib/node_modules/btc-rpc-explorer/node_modules/request/request.js:816:19)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at ClientRequest.emit (node:events:526:28)
  btcexp:errorVerbose     at Socket.emitRequestTimeout (node:_http_client:758:9)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at Socket.emit (node:events:538:35)
  btcexp:errorVerbose     at Socket._onTimeout (node:net:501:8)
  btcexp:errorVerbose     at listOnTimeout (node:internal/timers:559:17)
  btcexp:errorVerbose     at processTimers (node:internal/timers:502:7) +0ms
  btcexp:error Error RpcError-001: Error: ESOCKETTIMEDOUT, json: {"code":"ESOCKETTIMEDOUT","connect":false,"userData":{"request":"getblockchaininfo"}}, userData: [object Object] (json: {"request":"getblockchaininfo"}) +0ms
  btcexp:errorVerbose Stack: Error: ESOCKETTIMEDOUT
  btcexp:errorVerbose     at ClientRequest.<anonymous> (/usr/lib/node_modules/btc-rpc-explorer/node_modules/request/request.js:816:19)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at ClientRequest.emit (node:events:526:28)
  btcexp:errorVerbose     at Socket.emitRequestTimeout (node:_http_client:758:9)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at Socket.emit (node:events:538:35)
  btcexp:errorVerbose     at Socket._onTimeout (node:net:501:8)
  btcexp:errorVerbose     at listOnTimeout (node:internal/timers:559:17)
  btcexp:errorVerbose     at processTimers (node:internal/timers:502:7) +1ms
  btcexp:app Verifying RPC connection... +30s
  btcexp:app RPC Connected: version=220000 subversion=/Satoshi:22.0.0/, parsedVersion(used for RPC versioning)=22.0.0, protocolversion=70016, chain=main, services=[NETWORK, WITNESS, NETWORK_LIMITED] +78ms
  btcexp:app Loading historical data for chain=main +0ms
  btcexp:app Skipping performance-intensive task: fetch last 24 hrs of blockstats to calculate transaction volume. This is skipped due to the flag 'slowDeviceMode' which defaults to 'true' to protect slow nodes. Set this flag to 'false' to enjoy UTXO set summary details. +0ms
  btcexp:app txindex check: trying getindexinfo +0ms
  btcexp:app txindex check: getindexinfo={"txindex":{"synced":true,"best_block_height":588288}} +3ms
  btcexp:app txindex check: available! +0ms
  btcexp:app Skipping performance-intensive task: fetch UTXO set summary. This is skipped due to the flag 'slowDeviceMode' which defaults to 'true' to protect slow nodes. Set this flag to 'false' to enjoy UTXO set summary details. +0ms

Another log of another error when I attepmt to start btc_rpc_explorer:

btcexp:app Searching for config files... +0ms
  btcexp:app Config file found at /home/nomad/.config/btc-rpc-explorer.env, loading... +0ms
  btcexp:app Config file not found at /etc/btc-rpc-explorer/.env, continuing... +1ms
  btcexp:app Config file not found at /home/nomad/.env, continuing... +0ms
Loading RPC cookie file: /media/sf_B_DRIVE/.bitcoin/.cookie
  btcexp:app Default cacheId '3.3.0' +435ms
  btcexp:app Enabling view caching (performance will be improved but template edits will not be reflected) +14ms
  btcexp:app Environment(development) - Node: v16.14.2, Platform: linux, Versions: {"node":"16.14.2","v8":"9.4.146.24-node.20","uv":"1.43.0","zlib":"1.2.11","brotli":"1.0.9","ares":"1.18.1","modules":"93","nghttp2":"1.45.1","napi":"8","llhttp":"6.0.4","openssl":"1.1.1n+quic","cldr":"40.0","icu":"70.1","tz":"2021a3","unicode":"14.0","ngtcp2":"0.1.0-DEV","nghttp3":"0.1.0-DEV"} +5ms
  btcexp:app No sourcecode version available, continuing to use default cacheId '3.3.0' +0ms
  btcexp:app Starting BTC RPC Explorer, v3.3.0 at http://0.0.0.0:3002/ +0ms
  btcexp:app Connecting to RPC node at 127.0.0.1:8332 +0ms
  btcexp:app Verifying RPC connection... +4ms
  btcexp:app Loading mining pools config +0ms
  btcexp:app RPC Connected: version=220000 subversion=/Satoshi:22.0.0/, parsedVersion(used for RPC versioning)=22.0.0, protocolversion=70016, chain=main, services=[NETWORK, WITNESS, NETWORK_LIMITED] +863ms
  btcexp:app Loading historical data for chain=main +1ms
  btcexp:app Skipping performance-intensive task: fetch last 24 hrs of blockstats to calculate transaction volume. This is skipped due to the flag 'slowDeviceMode' which defaults to 'true' to protect slow nodes. Set this flag to 'false' to enjoy UTXO set summary details. +0ms
  btcexp:app txindex check: trying getindexinfo +0ms
  btcexp:app txindex check: getindexinfo={"txindex":{"synced":true,"best_block_height":588437}} +5ms
  btcexp:app txindex check: available! +0ms
  btcexp:app Skipping performance-intensive task: fetch UTXO set summary. This is skipped due to the flag 'slowDeviceMode' which defaults to 'true' to protect slow nodes. Set this flag to 'false' to enjoy UTXO set summary details. +0ms
  btcexp:error Error RpcError-001: Error: ESOCKETTIMEDOUT, json: {"code":"ESOCKETTIMEDOUT","connect":false,"userData":{"request":"getmempoolinfo"}}, userData: [object Object] (json: {"request":"getmempoolinfo"}) +0ms
  btcexp:errorVerbose Stack: Error: ESOCKETTIMEDOUT
  btcexp:errorVerbose     at ClientRequest.<anonymous> (/usr/lib/node_modules/btc-rpc-explorer/node_modules/request/request.js:816:19)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at ClientRequest.emit (node:events:526:28)
  btcexp:errorVerbose     at Socket.emitRequestTimeout (node:_http_client:758:9)
  btcexp:errorVerbose     at Object.onceWrapper (node:events:645:28)
  btcexp:errorVerbose     at Socket.emit (node:events:538:35)
  btcexp:errorVerbose     at Socket._onTimeout (node:net:501:8)
  btcexp:errorVerbose     at listOnTimeout (node:internal/timers:559:17)
  btcexp:errorVerbose     at processTimers (node:internal/timers:502:7) +0ms
Error: ESOCKETTIMEDOUT
    at ClientRequest.<anonymous> (/usr/lib/node_modules/btc-rpc-explorer/node_modules/request/request.js:816:19)
    at Object.onceWrapper (node:events:645:28)
    at ClientRequest.emit (node:events:526:28)
    at Socket.emitRequestTimeout (node:_http_client:758:9)
    at Object.onceWrapper (node:events:645:28)
    at Socket.emit (node:events:538:35)
    at Socket._onTimeout (node:net:501:8)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

bitcoin.conf is as such:

datadir=/media/sf_B_DRIVE/.bitcoin
txindex=1
server=1 

btc-rpc-explorer.env is as such:

# Optional logging settings, uncomment one of these example lines or add your own.
# See comments after each for more info.
# Default: "btcexp:app,btcexp:error"
#DEBUG=*  # Enable all logging, including middleware
#DEBUG=btcexp:*  # Enable all logging specific to btc-rpc-explorer
#DEBUG=btcexp:app,btcexp:error  # Default

# The base URL. If you want to run it elsewhere than on /, for example /btc-rpc-explorer/ - note that the value should include starting and ending "/"
# Default: /
#BTCEXP_BASEURL=/
#BTCEXP_BASEURL=/explorer/

# The active coin. Only officially supported value is "BTC".
# Default: BTC
#BTCEXP_COIN=BTC

# Host/Port to bind to
# Defaults: shown
BTCEXP_HOST=0.0.0.0
BTCEXP_PORT=3002

# Bitcoin RPC Credentials (URI -OR- HOST/PORT/USER/PASS)
# Defaults:
#   - [host/port]: 127.0.0.1:8332
#   - [username/password]: none
#   - cookie: '~/.bitcoin/.cookie'
#   - timeout: 5000 (ms)
#BTCEXP_BITCOIND_URI=bitcoin://rpcusername:rpcpassword@127.0.0.1:8332?timeout=10000
#BTCEXP_BITCOIND_HOST=127.0.0.1
#BTCEXP_BITCOIND_PORT=8332
#BTCEXP_BITCOIND_USER=rpcusername
#BTCEXP_BITCOIND_PASS=rpcpassword
BTCEXP_BITCOIND_COOKIE=/media/sf_B_DRIVE/.bitcoin/.cookie
#BTCEXP_BITCOIND_RPC_TIMEOUT=5000

# Select optional "address API" to display address tx lists and balances
# Options: electrum, electrumx, blockchain.com, blockchair.com, blockcypher.com
#
# If this value is set to electrum (or the old value "electrumx"), then
# BTCEXP_ELECTRUM_SERVERS must also be set
#
# Default: none
#BTCEXP_ADDRESS_API=(electrum|electrumx|blockchain.com|blockchair.com|blockcypher.com)

# Optional Electrum Protocol Servers. See BTCEXP_ADDRESS_API. This value is only
# used if BTCEXP_ADDRESS_API=electrum (or the old value "electrumx")
# 
# This variable was formerly named BTCEXP_ELECTRUMX_SERVERS and that name still works.
#
# Default: none
#BTCEXP_ELECTRUM_SERVERS=tls://electrumx.server.com:50002,tcp://127.0.0.1:50001,...

# Whether to use the Electrum server as an external txindex.
# This is only available in the Electrs implementation. Electrs txindex can serve as a
# full replacement for the Bitcoin Core txindex, but Bitcoin Core's implementation
# is likely faster.
#BTCEXP_ELECTRUM_TXINDEX=true

# Set number of concurrent RPC requests. Should be lower than your node's "rpcworkqueue" value.
# Note that Bitcoin Core's default rpcworkqueue=16.
# Default: 10
#BTCEXP_RPC_CONCURRENCY=10

# Disable app's in-memory RPC caching to reduce memory usage
# Default: false (i.e. in-memory cache **enabled**)
#BTCEXP_NO_INMEMORY_RPC_CACHE=true

# Optional redis server for RPC caching
# Default: none
#BTCEXP_REDIS_URL=redis://localhost:6379

# Default: hash of credentials
#BTCEXP_COOKIE_SECRET=0000aaaafffffgggggg

# Whether public-demo aspects of the site are active
# Default: false
#BTCEXP_DEMO=true

# Set to false to enable resource-intensive features, including:
# UTXO set summary querying
# (default value is true, i.e. resource-intensive features are disabled)
#BTCEXP_SLOW_DEVICE_MODE=false

# Privacy mode disables:
# Exchange-rate queries, IP-geolocation queries
# Default: false
#BTCEXP_PRIVACY_MODE=true

# Don't request currency exchange rates
# Default: true (i.e. no exchange-rate queries made)
#BTCEXP_NO_RATES=true

# Password protection for site via basic auth (enter any username, only the password is checked)
# Default: none
#BTCEXP_BASIC_AUTH_PASSWORD=mypassword

# File where the SSO token is stored; ignored if BTCEXP_BASIC_AUTH_PASSWORD is provided.
# Enables SSO if present.
# Default: none
#BTCEXP_SSO_TOKEN_FILE=/var/run/btc-rpc-explorer/sso_token

# URL of an optional external SSO provider
# This is ignored if SSO is not enabled (see BTCEXP_SSO_TOKEN_FILE)
# Default: none
#BTCEXP_SSO_LOGIN_REDIRECT_URL=/my-sso-provider/login

# Enable to allow access to all RPC methods
# Default: false
#BTCEXP_RPC_ALLOWALL=true

# Custom RPC method blacklist
# Default: (see config.js)
#BTCEXP_RPC_BLACKLIST=signrawtransaction,sendtoaddress,stop,...

# Optional API keys
# Default: none
#BTCEXP_GANALYTICS_TRACKING=UA-XXXX-X
#BTCEXP_SENTRY_URL=https://00000fffffff@sentry.io/XXXX
#BTCEXP_IPSTACK_APIKEY=000000fffffaaaaa
#BTCEXP_MAPBOX_APIKEY=000000fffffaaaaa

# Optional value for a directory for filesystem caching
# Default: ./cache
#BTCEXP_FILESYSTEM_CACHE_DIR=./cache

# Optional analytics
#BTCEXP_PLAUSIBLE_ANALYTICS_DOMAIN=domain.com
#BTCEXP_PLAUSIBLE_ANALYTICS_SCRIPT_URL=https://url-to/plausible.js

# Optional value for "max_old_space_size"
# Default: 1024
#BTCEXP_OLD_SPACE_MAX_SIZE=2048

# The number of recent blocks to search for transactions when txindex is disabled
#BTCEXP_NOTXINDEX_SEARCH_DEPTH=3

# Display Currency
# Default: btc
#BTCEXP_DISPLAY_CURRENCY=(btc|sat|local)

# Local Currency
# Default: usd
#BTCEXP_LOCAL_CURRENCY=(usd|eur|...)

# UI Timezone
# Default: utc
#BTCEXP_UI_TIMEZONE=(utc|local)

# UI Theme
# Default: dark
#BTCEXP_UI_THEME=(dark|light)

# UI Option: Hide info notes
# Default: false
#BTCEXP_UI_HIDE_INFO_NOTES=(true|false)

# Set the number of recent blocks shown on the homepage.
# For slow devices reduce this number.
# Default: 10
#BTCEXP_UI_HOME_PAGE_LATEST_BLOCKS_COUNT=10

# Set the number of blocks per page on the browse-blocks page.
# For slow devices reduce this number.
# Default: 50
#BTCEXP_UI_BLOCKS_PAGE_BLOCK_COUNT=50
janoside commented 2 years ago

@oscarmike556 This looks like fairly normal behavior. From what I see, it looks like the first few RPC requests failed at startup, but after a delay they succeeded on a retry. This would be especially normal if you're running on slow hardware, and/or if Bitcoin Core were recently started.

Aside from the above explanation, I'd like to know: after those errors, and the subsequent successful retries, did the app startup and run correctly?

janoside commented 1 year ago

Cleaning up old issues. If you're still having this problem using the latest code (3.4-beta or greater), feel free to reply.