cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.84k stars 1.77k forks source link

I'm encountering a 'connect ETIMEDOUT' error in cubejs backend api #7970

Open a-khan-cubeone opened 6 months ago

a-khan-cubeone commented 6 months ago

"Hey everyone, I'm currently working on integrating Cube.js backend API with MySQL, but I'm encountering a 'connect ETIMEDOUT' error. I'm using Node.js version 16. Any ideas on how to troubleshoot or resolve this issue? Your assistance would be much appreciated. Thanks!"

"dependencies": {
    "@cubejs-backend/mongobi-driver": "^0.29.0",
    "@cubejs-backend/mysql-driver": "^0.29.0",
    "@cubejs-backend/server": "^0.29.0"
  }
}

here is my graphql code:

import { formatLockVisibilityConstraintsSql } from './helpers';

cube(`Lock`, {
  sql: `SELECT _id, lockId, shortName, timeZone FROM \`Lock\` WHERE (
    _id in ('${formatLockVisibilityConstraintsSql(USER_CONTEXT.adminKeys.unsafeValue())}')
  )`,
  // sql: `SELECT _id, lockId, shortName, _created_at FROM \`Lock\``,

  refreshKey: {
    sql: `SELECT GREATEST(
            (SELECT _created_at FROM \`Lock\` ORDER BY _created_at DESC LIMIT 1),
            (SELECT _updated_at FROM \`Lock\` ORDER BY _updated_at DESC LIMIT 1)
          )`
  },

  joins: {
    KeyRelationship: {
      relationship: `hasMany`,
      sql: `CONCAT("Lock$", ${CUBE}.objectId) = ${KeyRelationship}._p_key`
    },

    // Action: {
    //   relationship: `hasMany`,
    //   sql: `CONCAT("Lock$", ${CUBE}.objectId) = ${Action}._p_lock`
    // },

    // Unlock: {
    //   relationship: `belongsTo`,
    //   sql: `CONCAT("Lock$", ${CUBE}.objectId) = ${Unlock}._p_lock`
    // }
  },

  dimensions: {
    objectId: {
      sql: `${CUBE}.\`_id\``,
      shown: false,
      type: `string`,
      primaryKey: true
    },

    lockId: {
      sql: `${CUBE}.\`lockId\``,
      shown: true,
      type: `string`,
      title: `Lock ID`,
      meta: {
        columnFlex: .5
      }
    },

    shortName: {
      sql: `${CUBE}.\`shortName\``,
      shown: true,
      type: `string`,
      title: `Lock Short Name`
    },

    displayName: {
      sql: `${CUBE}.\`shortName\``,
      shown: true,
      type: `string`,
      title: `Lock Display Name`,
      meta: {
        linkIfAvailable: `Lock.portalLink`,
      }
    },

    portalLink: {
      sql: `CONCAT('/keys/', ${lockId})`,
      type: `string`,
      format: `link`
    },

    // timeZone: {
    //   sql: `${CUBE}.\`timeZone\``,
    //   shown: true,
    //   type: `string`,
    //   title: `Time Zone`
    // },
  },

  preAggregations: {
    main: {
      external: true,
      type: `originalSql`,
      indexes: {
        main: {
          columns: ['_id']
        },
        // time: {
        //   columns: ['_created_at']
        // }
      }
    }
  }
});

image (1)

igorlukanin commented 6 months ago

Hi @a-khan-cubeone 👋 The error suggests that Cube was unable to connect to your MySQL database. Could you please verify that it works and is reachable over the network?

If you're running Cube in a container, please make sure that Docker networking is configured appropriately: https://cube.dev/docs/product/deployment/core#configuration