2017-10-15 30 views
0

我在web應用程序中使用mysql2節點包(v1.2.0),並且當我使用debbugger(使用webstorm)遍歷代碼時,如果我坐在某些斷點處時間過長,有時會啓動連接時間到。節點應用程序:如何在debbuging時增加mysql2的超時時間?

這是我收到時超時消息:

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 
}); 

但是這沒有效果。

回答

1

,爲連接超時屬性爲connectTimeout,不只是timeout。該documentation的(兼容)的MySQL包讀取:

connectTimeout:MySQL服務器的初始連接過程中發生超時的毫秒之前。 (默認:10000

0

MySQL也有它自己的超時。如果超時是在客戶端上你可以修改它likeso(從here

con.query('SET GLOBAL connect_timeout=28800') 
con.query('SET GLOBAL wait_timeout=28800') 
con.query('SET GLOBAL interactive_timeout=28800') 
相關問題