[英]Node application: How to increase timeout for mysql2 when debbuging?
I'm using the mysql2 node package (v1.2.0) in a web application and when I'm stepping through the code using the debbugger (using webstorm), if I sit too long at certain breakpoints, initiating the connection will sometimes time out. 我在Web应用程序中使用mysql2节点程序包(v1.2.0),当我使用调试器(使用webstorm)单步执行代码时,如果我在某些断点处坐的时间太长,则启动连接有时会超时。
Here's the message I receive when it times out: 这是我超时时收到的消息:
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)
I was hoping to increase the timeout to avoid this issue. 我希望增加超时以避免此问题。 I tried adding a custom timeout value for when the connection is set up.
我尝试为连接建立时添加自定义超时值。
export const connection = mysql.createConnection({
host: dbHost,
user: dbUser,
password: dbPassword,
database: dbName,
timeout: 60000
});
But this had no effect. 但这没有效果。
If the timeout is on the client, the property for the connection timeout is connectTimeout
, not just timeout
. 如果超时在客户端上,则连接超时的属性为
connectTimeout
,而不仅仅是timeout
。 The documentation for the (compatible) mysql package reads: (兼容)mysql软件包的文档内容如下:
connectTimeout
: The milliseconds before a timeout occurs during the initial connection to the MySQL server.connectTimeout
:与MySQL服务器的初始连接期间发生超时之前的毫秒数。 (Default:10000
)(默认值:
10000
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.