Javascript 节点应用程序:在解除Bugging时如何增加mysql2的超时?

Javascript 节点应用程序:在解除Bugging时如何增加mysql2的超时?,javascript,mysql,node.js,Javascript,Mysql,Node.js,我在web应用程序中使用mysql2节点包(v1.2.0),当我使用debbugger(使用webstorm)单步执行代码时,如果我在某些断点处停留太久,启动连接有时会超时 以下是我在超时时收到的消息: Error: connect ETIMEDOUT at Connection._handleTimeoutError (/Volumes/github-image/bitcoin-core/node_modules/mysql2/lib/connection.js:179:13)

我在web应用程序中使用mysql2节点包(v1.2.0),当我使用debbugger(使用webstorm)单步执行代码时,如果我在某些断点处停留太久,启动连接有时会超时

以下是我在超时时收到的消息:

Error: connect ETIMEDOUT
    at Connection._handleTimeoutError (/Volumes/github-image/bitcoin-core/node_modules/mysql2/lib/connection.js:179:13)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
我希望增加超时以避免此问题。我尝试在建立连接时添加自定义超时值

export const connection = mysql.createConnection({
  host: dbHost,
  user: dbUser,
  password: dbPassword,
  database: dbName,
  timeout: 60000
});

但是这没有效果。

MySQL也有自己的超时。您可以像这样修改它(从)


如果超时在客户端上,则连接超时的属性是
connectTimeout
,而不仅仅是
timeout
。(兼容)mysql包的代码如下:

connectTimeout
:初始连接到MySQL服务器期间发生超时之前的毫秒数。(默认值:
10000

con.query('SET GLOBAL connect_timeout=28800')
con.query('SET GLOBAL wait_timeout=28800')
con.query('SET GLOBAL interactive_timeout=28800')