mempool icon indicating copy to clipboard operation
mempool copied to clipboard

Cannot get fetch orphaned blocks. Reason: ETIMEDOUT

Open nailujac opened this issue 2 years ago • 3 comments

Description

With the installation of Docker, upon starting it with docker-compose, it fails to synchronize completely.

Version

https://github.com/mempool/mempool/commit/7c09dd1b70cf8b777b9ea1b4f03e79398a596079

Steps to reproduce

Run with docker-compose

Expected behaviour

Complete synchronization

Actual behaviour

Gest this error:

docker-api-1  | Oct  9 19:57:06 [121] ERR: Cannot get fetch orphaned blocks. Reason: ETIMEDOUT
docker-api-1  | Oct  9 19:57:06 [121] NOTICE: Mempool Server is running on port 8999
docker-api-1  | Oct  9 20:01:11 [121] WARN: Exception in runMainUpdateLoop(). Retrying in 10 sec. Reason: ETIMEDOUT. Stack trace: Error: ETIMEDOUT
docker-api-1  |     at Timeout._onTimeout (/backend/package/rpc-api/jsonrpc.js:66:23)
docker-api-1  |     at listOnTimeout (node:internal/timers:559:17)
docker-api-1  |     at processTimers (node:internal/timers:502:7)
docker-api-1  | Oct  9 20:03:21 [121] WARN: Exception in runMainUpdateLoop(). Retrying in 20 sec. Reason: ETIMEDOUT. Stack trace: Error: ETIMEDOUT
docker-api-1  |     at Timeout._onTimeout (/backend/package/rpc-api/jsonrpc.js:66:23)
docker-api-1  |     at listOnTimeout (node:internal/timers:559:17)
docker-api-1  |     at processTimers (node:internal/timers:502:7)
docker-api-1  | Oct  9 20:05:41 [121] WARN: Exception in runMainUpdateLoop(). Retrying in 40 sec. Reason: ETIMEDOUT. Stack trace: Error: ETIMEDOUT
docker-api-1  |     at Timeout._onTimeout (/backend/package/rpc-api/jsonrpc.js:66:23)
docker-api-1  |     at listOnTimeout (node:internal/timers:559:17)
docker-api-1  |     at processTimers (node:internal/timers:502:7)
docker-api-1  | Oct  9 20:08:21 [121] WARN: Exception in runMainUpdateLoop(). Retrying in 60 sec. Reason: ETIMEDOUT. Stack trace: Error: ETIMEDOUT
docker-api-1  |     at Timeout._onTimeout (/backend/package/rpc-api/jsonrpc.js:66:23)
docker-api-1  |     at listOnTimeout (node:internal/timers:559:17)
docker-api-1  |     at processTimers (node:internal/timers:502:7)

Screenshots

image

Device or machine

  • Ubuntu server.
  • Bitcoin core and Electrum Server Fulcrum

Additional info

nailujac avatar Oct 09 '23 20:10 nailujac

It's an issue with your setup. Your nodejs backend probably cannot access your bitcoin core RPC.

nymkappa avatar Oct 10 '23 09:10 nymkappa

Thank you @nymkappa. Your are right. It was necessary to include the IP and subnet of the Docker container with rpcbind and rpcallowip in the bitcoin.conf file.

rpcbind=127.0.0.1
rpcbind=172.18.0.1
rpcallowip=127.0.0.1
rpcallowip=172.18.0.0/16

Now it synchronizes correctly.

On the other hand, I have the following question now: I'm trying to configure the proxy in the API container so that requests to external services are made through Tor (get prices, for example). In other words, I want to use Tor installed in machine from Docker container. This is the configuration I have:

docker-compose.yml

SOCKS5PROXY_ENABLED: "true"
SOCKS5PROXY_USE_ONION: "true"
SOCKS5PROXY_HOST: "172.18.0.1" # This is the container gateway IP to access the host machine
SOCKS5PROXY_PORT: "9050"

/etc/tor/torrc

SocksPort 9050
SocksPort 172.18.0.1:9050
SocksPolicy accept 172.18.0.0/16

Firewall ufw disabled.

And I am getting the following errors:

docker-api-1  | Oct 11 06:28:30 [108] WARN: Could not connect to https://api.exchange.coinbase.com/products/BTC-USD/candles?granularity=3600 (Attempt 1/1). Reason: Request failed with status code 403
docker-api-1  | Oct 11 06:28:30 [108] ERR: Could not connect to https://api.exchange.coinbase.com/products/BTC-USD/candles?granularity=3600. All 1 attempts failed
docker-api-1  | Oct 11 06:28:31 [108] WARN: Could not connect to https://api.exchange.coinbase.com/products/BTC-EUR/candles?granularity=3600 (Attempt 1/1). Reason: Request failed with status code 403
docker-api-1  | Oct 11 06:28:31 [108] ERR: Could not connect to https://api.exchange.coinbase.com/products/BTC-EUR/candles?granularity=3600. All 1 attempts failed
docker-api-1  | Oct 11 06:28:32 [108] WARN: Could not connect to https://api.exchange.coinbase.com/products/BTC-GBP/candles?granularity=3600 (Attempt 1/1). Reason: Request failed with status code 403
docker-api-1  | Oct 11 06:28:32 [108] ERR: Could not connect to https://api.exchange.coinbase.com/products/BTC-GBP/candles?granularity=3600. All 1 attempts failed

Initially, I thought these services wouldn't allow requests from the Tor network, but when I try from the Tor browser, I do get a response. Any idea what might be happening?

I've also noticed in the configuration file that there are certain parameters that include onion addresses. For example:

PRICE_DATA_SERVER": {
   "TOR_URL": "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices",
   "CLEARNET_URL": "https://price.bisq.wiz.biz/getAllMarketPrices"
},

"EXTERNAL_DATA_SERVER": {
   "MEMPOOL_API": "https://mempool.space/api/v1",
   "MEMPOOL_ONION": "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/api/v1",
   "LIQUID_API": "https://liquid.network/api/v1",
   "LIQUID_ONION": "http://liquidmom47f6s3m53ebfxn47p76a6tlnxib3wp6deux7wuzotdr6cyd.onion/api/v1",
   "BISQ_URL": "https://bisq.markets/api",
   "BISQ_ONION": "http://bisqmktse2cabavbr2xjq7xw3h6g5ottemo5rolfcwt6aly6tp5fdryd.onion/api"
}

When are these addresses used?

Thank you

nailujac avatar Oct 11 '23 06:10 nailujac

I think I know what's going on. The 403 error only occurs when invoking some endpoints (for example, coinbase and bitfinex). I've reproduce it using the curl command, and I get the same result. To resolve it, I have to pass the --cookie option. For example:

curl -v --cookie --socks5 127.0.0.1:9050 https://api.exchange.coinbase.com/products/BTC-USD/candles?granularity=3600

According to the documentation for this option of the command:

This option also activates the cookie engine which makes curl record incoming cookies, which may be handy if you are using this in combination with the -L, --location option or do multiple URL transfers on the same invoke.

To solve this, I suppose it would be sufficient to use the corresponding parameterization in Axios.

nailujac avatar Oct 11 '23 18:10 nailujac