scantxoutset fails via javascript rpc call in mainnet (ok in testnet) with: OperationalError: ESOCKETTIMEDOUT #21774

issue educob openend this issue on April 25, 2021
  1. educob commented at 8:51 am on April 25, 2021: none

    Hi.

    I can successfully request utxos in mainnet with: bitcoin-cli -rpcport=8332 -rpcuser=xxxx -rpcpassword=xxxx scantxoutset start '["addr(bc1qnffp2jccqnwjwymkheqkkkrgdhslxyg3wpu0rq)"]'

    But

    0const Client = require('bitcoin-core')
    1let btcNode = new Client( { host, username, password, port, timeout: 30000 } ) 
    2const address = { _id: 'bc1qnffp2jccqnwjwymkheqkkkrgdhslxyg3wpu0rq', ...}
    3const utxos = await btcNode.command('scantxoutset', 'start', [`addr(${address._id})`])
    

    fails in mainnet (ok in testnet) with

     0OperationalError: ESOCKETTIMEDOUT
     1    at ClientRequest.<anonymous> (/graphql/node_modules/request/request.js:816:19)
     2    at Object.onceWrapper (events.js:421:28)
     3    at ClientRequest.emit (events.js:315:20)
     4    at ClientRequest.EventEmitter.emit (domain.js:485:12)
     5    at Socket.emitRequestTimeout (_http_client.js:717:9)
     6    at Object.onceWrapper (events.js:421:28)
     7    at Socket.emit (events.js:327:22)
     8    at Socket.EventEmitter.emit (domain.js:485:12)
     9    at Socket._onTimeout (net.js:481:8)
    10    at listOnTimeout (internal/timers.js:549:17)
    11    at processTimers (internal/timers.js:492:7) {
    12  cause: Error: ESOCKETTIMEDOUT
    13      at ClientRequest.<anonymous> (/graphql/node_modules/request/request.js:816:19)
    14      at Object.onceWrapper (events.js:421:28)
    15      at ClientRequest.emit (events.js:315:20)
    16      at ClientRequest.EventEmitter.emit (domain.js:485:12)
    17      at Socket.emitRequestTimeout (_http_client.js:717:9)
    18      at Object.onceWrapper (events.js:421:28)
    19      at Socket.emit (events.js:327:22)
    20      at Socket.EventEmitter.emit (domain.js:485:12)
    21      at Socket._onTimeout (net.js:481:8)
    22      at listOnTimeout (internal/timers.js:549:17)
    23      at processTimers (internal/timers.js:492:7) {
    24    code: 'ESOCKETTIMEDOUT',
    25    connect: false
    26  },
    27  isOperational: true,
    28  code: 'ESOCKETTIMEDOUT',
    29  connect: false
    30}
    

    Other commands like btcNode.sendRawTransaction estimateSmartFee getBlockByHash works ok.

    Thanks.

    update: in the server I opened a single btcNode connection that I reuse all the time.

  2. educob added the label Bug on Apr 25, 2021
  3. jonatack commented at 8:57 am on April 25, 2021: member
    Hi @educob, do you see this issue when running the RPC manually on the command line?
  4. jonatack commented at 9:00 am on April 25, 2021: member
    (Ok, the command line works. It looks like the issue here isn’t with Bitcoin Core.)
  5. educob commented at 9:01 am on April 25, 2021: none
    You mean with “bitcoin-cli”? It works ok with bitcoin-cli. It only fails with rpc javascript for scantxoutset.
  6. MarcoFalke commented at 9:16 am on April 25, 2021: member
    Can you report the issue to the javascript library? This is the issue tracker for Bitcoin Core.
  7. educob commented at 9:18 am on April 25, 2021: none
    I’ll do that. I t hought it was a Bitcoin Core issue as it’s the node giving a socket timeout.
  8. MarcoFalke removed the label Bug on Apr 25, 2021
  9. MarcoFalke added the label Upstream on Apr 25, 2021
  10. MarcoFalke commented at 9:19 am on April 25, 2021: member
    What is time bitcoin-cli -rpcport=8332 -rpcuser=xxxx -rpcpassword=xxxx scantxoutset start '["addr(bc1qnffp2jccqnwjwymkheqkkkrgdhslxyg3wpu0rq)"]'?
  11. MarcoFalke commented at 9:21 am on April 25, 2021: member
    Also, what is -rpcservertimeout (on the server)?
  12. educob commented at 9:21 am on April 25, 2021: none

    It says time: not found.

    I think this is a bitcoin core issue cause it works in testnet but not in mainet.

  13. MarcoFalke commented at 9:21 am on April 25, 2021: member
    How long does it take to execute the bitcoin-cli command?
  14. sipa commented at 9:23 am on April 25, 2021: member

    presumably the javascript library uses a timeout that is too low for how long the operation actually takes

    Bitcoin Core doesn’t know or care whether the client is js or bitcoin-cli.

  15. educob commented at 9:25 am on April 25, 2021: none

    it takes 39 seconds. An eternity.

    Why does it take so long?

    Thanks for your answers.

  16. educob commented at 9:26 am on April 25, 2021: none

    I haven’t set rpcservertimeout on the server.

    What should be a reasonable value?

  17. MarcoFalke commented at 9:39 am on April 25, 2021: member

    The default for -rpcclienttimeout on the client (bitcoin-cli) is 900. You set the timeout to 30000 (which I presume is 30 seconds)?

    So you can fix your issue by increasing the timeout in your JavaScript code.

  18. MarcoFalke closed this on Apr 25, 2021

  19. educob commented at 12:09 pm on April 25, 2021: none

    Thanks.

    But I am troubled by the fact that it takes 39 seconds to look up an address without a single utxo. It this normal?

  20. MarcoFalke commented at 12:31 pm on April 25, 2021: member
    The utxo set is several GB of data. scantxoutset is linear complexity in the size of the set, because the utxo set is not indexed by address (or scriptPubKey).
  21. MarcoFalke commented at 12:33 pm on April 25, 2021: member
    If you need faster performance you could try a (watch-only) wallet or an external service (see #14053 for discussion)
  22. educob commented at 12:37 pm on April 25, 2021: none

    Thanks for your help.

    Have a nice day.

    (I don’t see the option to close the issue)

  23. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me