telosnetwork / telos-evm-docker

Automated Telos EVM development and automated test framework
Apache License 2.0
12 stars 3 forks source link

Fix `hyperion-api` connection error to `elasticsearch` #86

Closed guilledk closed 1 year ago

guilledk commented 1 year ago

Fixes #84

Description

In both 1.0 and 1.5 branches we get this error on startup of hyperion-api container:

2023-03-16T22:41:06: [36 - 00_master] an error happened ConnectionError: connect ECONNREFUSED ::1:9200
    at ClientRequest.onError (/hyperion-history-api/node_modules/@elastic/elasticsearch/lib/Connection.js:123:16)
    at ClientRequest.emit (node:events:513:28)
    at ClientRequest.emit (node:domain:489:12)
    at Socket.socketErrorListener (node:_http_client:502:9)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  meta: {
    body: null,
    statusCode: null,
    headers: null,
    meta: {
      context: null,
      request: [Object],
      name: 'elasticsearch-js',
      connection: [Object],
      attempts: 3,
      aborted: false
    }
  }
}

If you look closely at the error you can see that hyperion-api is trying to query ::1:9200 for elastic, that is ipv6 localhost, this is cause when using docker host networking mode, the host system's /etc/hosts file gets binded inside the container, so depending on the specific user config this will break.

Solution is to swap to specific ipv4 localhost in all necesary fields.