gpt4 book ai didi

mysql - 我的 Firebase 云函数给出 SequelizeConnectionError : connect ETIMEDOUT error whenever I query my MySql DB

转载 作者:行者123 更新时间:2023-11-29 10:10:44 25 4
gpt4 key购买 nike

问题描述:

我正在使用 Sequalize ORM 和我的 Firebase 云函数,每当我查询 MySql DB 时,都会出现 SequelizeConnectionError: connect ETIMEDOUT 错误。当函数通过 Firebase cli 在本地主机上运行时,它工作正常。下面是Sequalize连接方法。

代码片段

var sequelize = new Sequelize('dbname, 'username', 'password', {
host: "host",
dialect: 'mysql',
define: {
paranoid: true
},
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 1
},
operatorsAliases: false})

当函数通过 Firebase CLI 在端口 5000 上本地运行时,上述代码运行完美。当我将其部署在 Firebase 上并运行相同的函数时,我收到以下错误。

2018-06-23T11:31:53.887Z E app: Unhandled rejection
2018-06-23T11:31:55.187Z E app: SequelizeConnectionError: connect ETIMEDOUT
at Utils.Promise.tap.then.catch.err (/user_code/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:149:19)
at tryCatcher (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/user_code/node_modules/sequelize/node_modules/bluebird/js/release/async.js:17:14
)

最佳答案

这很可能是因为您的 Firebase 项目采用免费的 Spark 付款计划。使用 Spark,您的 Cloud Functions 无法与不受 Google 完全控制的服务建立传出连接。要建立传出连接,您必须将项目升级到其中一种付款计划,例如 Blaze。

Read more on the Firebase pricing page.

关于mysql - 我的 Firebase 云函数给出 SequelizeConnectionError : connect ETIMEDOUT error whenever I query my MySql DB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51001037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com