node.js mysql socket error after stress test

I use node.js, an asynchronous event base server with mysql module to select 122 rows of records from the database. I ran a simple stress test using the command below: ab -n 10 -c 2 http://localhost:8000/ the node.js finish the process, but mysql is still running, until it hits an error: throw new Error('Socket is not writable'); ^ Error: Socket is not writable at Socket._writeOut (net.js:391:11) at Socket.write (net.js:377:17) at Client.write (/home/kelvin/node_modules/mysql/lib/client.js:142:16) at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:240:10) at Client._dequeue (/home/kelvin/node_modules/mysql/lib/client.js:274:18) at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:247:10) at Client._dequeue (/home/kelvin/node_modules/mysql/lib/client.js:274:18) at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:247:10) at Client._dequeue (/home/kelvin/node_modules/mysql/lib/client.js:274:18) at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:247:10) Now whenever I run the test again, I get the same error. Is MySQL a good solution to use with Node.js or is it how I code? Some node.js code: var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); client.query('USE ' + db); client.query('SELECT * FROM ' + tbl, function selectDb(err, results, fields) { if (err) { throw err; } console.log(results); client.end(); } ); response.end("END RESULT"); });

以上就是node.js mysql socket error after stress test的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » Node.js答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏