1

I'm trying to figure out how to connect my NodeJS app to a remote monero node. I need it to query the network.

Here's is the list of available JSON-RPC methods — Daemon RPC documentation

Here's the list of open nodes — https://moneroworld.com/

Here's what I do:

const rpc = require('json-rpc-client')
const host = 'node.moneroworld.com'
const port = '18089'
const client = new rpc({ host, port })
client.connect()
  .then(() => {
    console.log('Connected')
  })
  .catch(error => {
    console.log(error)
  })

Here's the error:

{ host: 'node.moneroworld.com', port: '18089' }
error:Error: getaddrinfo ENOTFOUND node.moneroworld.com node.moneroworld.com:18089
{ Error: getaddrinfo ENOTFOUND node.moneroworld.com node.moneroworld.com:18089
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:26)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'node.moneroworld.com',
  host: 'node.moneroworld.com',
  port: '18089' }

When I use another host:

const host = 'node.xmrbackb.one'
const port = '18081'

I get:

{ host: 'node.xmrbackb.one', port: '18081' }
error:Error: connect ETIMEDOUT 116.93.119.79:18081
{ Error: connect ETIMEDOUT 116.93.119.79:18081
    at Object.exports._errnoException (util.js:1034:11)
    at exports._exceptionWithHostPort (util.js:1057:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1096:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '116.93.119.79',
  port: 18081 }

I can't event connect to a node. What am I missing?

1

I've found a solution, using monero-rpc-client library. When I use node.moneroworld.com:18089 as host, the code doesn't work. When ip is used instead everything is OK. The ip is taken from here.

const rpcClientClass = require('monero-rpc-client')
const nodeAddress = 'http://62.210.124.152:18089'
const rpcClient = new rpcClientClass(nodeAddress)
rpcClient.getBlockCount()
  .then(result => {
    console.log(result)
  })
  .catch(error => {
    console.log(error)
  })

Here's the result:

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "count": 1492683,
    "status": "OK"
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.