arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
601 stars 107 forks source link

Sometimes ETIMEDOUT when connecting to ArangoDB #712

Closed mstimvol closed 3 years ago

mstimvol commented 3 years ago

I'm running a single ArangoDB (no cluster atm) in a Kubernetes cluster and everything works fine, but sometimes I'm having trouble connecting to my ArangoDB. I've a very simple application that looks like:

const arango = require('arangojs')

async function test () {
  const db = new arango.Database({
    url: 'http://<some-ip-addr>:8529',
    databaseName: 'somedb',
    auth: {
      username: 'root',
      password: 'mypassword'
    }
  })

  const col = db.collection('test')
  console.log('Exists:', await col.exists())
}

test()

When I start the application, I'm often getting the following error message:

(node:29612) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT <some-ip-addr>:8529
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:29612) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:29612) [DEP0018] DeprecationWarning: Unhandled promise rejectio
ns are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:29612) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT <some-ip-addr>:8529
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
(node:29612) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

When I use try/catch around "await col.exists()" I'm getting the following error:

Error: connect ETIMEDOUT <some-ip-addr>:8529
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -4039,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '<some-ip-addr>',
  port: 8529,
  request: <ref *1> ClientRequest {
    _events: [Object: null prototype] {
      response: [Function],
      timeout: [Function (anonymous)],
      error: [Function (anonymous)]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: true,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: false,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: 0,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    socket: Socket {
      connecting: false,
      _hadError: true,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 8,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: 'GET /_db/_system/_api/collection/test HTTP/1.1\r\n' +
        'authorization: Basic <removed :-)>\r\n' +
        'content-type: text/plain\r\n' +
        'x-arango-version: 30400\r\n' +
        'Host: <some-ip-addr>:8529\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _pendingEncoding: 'latin1',
      server: null,
      _server: null,
      parser: null,
      _httpMessage: [Circular *1],
      [Symbol(async_id_symbol)]: 10,
      [Symbol(kHandle)]: null,
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0
    },
    _header: 'GET /_db/_system/_api/collection/test HTTP/1.1\r\n' +
      'authorization: Basic <removed :-)>\r\n' +
      'content-type: text/plain\r\n' +
      'x-arango-version: 30400\r\n' +
      'Host: <some-ip-addr>:8529\r\n' +
      'Connection: keep-alive\r\n' +
      '\r\n',
    _keepAliveTimeout: 0,
    _onPendingData: [Function: noopPendingOutput],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 80,
      protocol: 'http:',
      options: [Object],
      requests: {},
      sockets: [Object],
      freeSockets: {},
      keepAliveMsecs: 1000,
      keepAlive: true,
      maxSockets: 3,
      maxFreeSockets: 256,
      scheduling: 'fifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 1,
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'GET',
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    path: '/_db/_system/_api/collection/test',
    _ended: false,
    res: null,
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    host: '<some-ip-addr>',
    protocol: 'http:',
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      authorization: [Array],
      'content-type': [Array],
      'x-arango-version': [Array],
      host: [Array]
    }
  }
}

When I start the application 5 times, I'm getting this error on 3 or 4 starts. On 1 or 2 starts it works. But I'm connected to the web-interface using Firefox without any problems. I'm running a single instance of ArangoDB 3.7.3, using arangojs 7.1.1 (previously tried with arangojs 7.2.0) using Node.js 14.14.0.

Any suggestions?

mstimvol commented 3 years ago

I finally figured out that it was a problem on my side that interrupted the connection because of a while-loop.