I ' mrunninganodeserverconnectingtomysqlviathenode-MySQL module.connectingtoandqueryingmysqlworksgreatinitiallywithoutanyeratanyeryer thefirstqueryafterleavingthenodeserveridleforacouplehoursresultsinanerror.therroristhefamiliarreadeconnreset,however,therrred
astacktrace (notethatthethreeentriesofthetracebelongtomyapp ' serrorreportingcode ) :
错误发生器
at exports.error.utils.create class.init (d : (site (ww root (errors.js 3360180:16 ) ) )。
atnewnewclass (d : (home (site (wwwroot ) utils.js336068:14 ) )。
at query._ callback (d : (home (site ) wwroot ) db.js:281:21 ) )。
at query.sequence.end (d :homesiteww rootnode _ modulesMySQLlibprotocolsequ sencesse )
at protocol.handlenetworkerror (d :homesitewwwrootnode _ modulesMySQLlibprotocolprotocol
atpool connection.connection._ handlenetworkerror (d :homesiteww rootnode _ modules _ MySQLlib )
at socket.event emitter.emit (events.js :95336017 ) )。
at net.js:441:14
at process._ tick callback (node.js :415336013 )。
thiserrorhappensbothonmycloudnodeserverandmysqlserveraswellasalocalsetupofpsdbks/pmy questions 3360
doesthisproblemappeartobeadisconnectionofnode ' sconnectiontomymysqlserver (s,perhapsduetoaconnectionlifetimelimitation?
When using connection pools,node-mysqlissupposedtogracefullyhandledisconnectionsandprunethemfromthepool.isitnotawareofthedidiol
consideringthatiseethe ' readeconnreset ' erroralotinotherstackoverflowposts,shouldibelookingelsewherefrommmysqltodiagnosethe
Update: After more browsing,ithinkmyissueisaduplicateofthisone.itappearshisconnectionisdisconnectingaswell, butnoonehassuggestedhowtokeeptheconnectionaliveorhowtoaddresstheerroroutsideoffailingonthefirstqueryback。
解决方案
ireachedouttothenode-mysqlfolksontheirgithubpageandgotsomefirmanswers。
According to this issue, 节点- MySQL doesn ' tprunepoolconnectionsafterthesesortsofdisconnections.themoduledevelopersrecommendedusingaheartbeattokep dedusingthenode-poolmoduleanditsidletimeoutmillisoptiontoautomaticallypruneidleconnections。