0

Ok, so i have a database intergrated using nodejs mysql it works perfectly fine 99% of the time however when doing a longer execution process it decides to act up and give me this error every single time.

Error: connect ETIMEDOUT
    at Connection._handleConnectTimeout (/root/bot/node_modules/mysql/lib/Connection.js:409:13)
    at Object.onceWrapper (events.js:421:28)
    at Socket.emit (events.js:315:20)
    at Socket._onTimeout (net.js:481:8)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
    --------------------
    at Protocol._enqueue (/root/bot/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/root/bot/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/root/bot/node_modules/mysql/lib/Connection.js:116:18)
    at Connection._implyConnect (/root/bot/node_modules/mysql/lib/Connection.js:454:10)
    at Connection.query (/root/bot/node_modules/mysql/lib/Connection.js:196:8)
    at Client.<anonymous> (/root/bot/bot.js:281:7)
    at Client.emit (events.js:327:22)
    at MessageCreateAction.handle (/root/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/root/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/root/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31) {
  errorno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  fatal: true
}

In all other locations and functions it works perfectly fine however this dosent. Ive tried setting the timeouts like this.

[mysqld]
max_connections=200
wait_timeout = 31536000
interactive_timeout = 31536000
connect_timeout=31536000

and inside the actual program like this.

var con = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "passwd",
    timeout: 6000000,
    database: "bot"
  }); // MYSQL Connection

Still times out. This is driving me crazy can anyone provide some help or insight here?

Thanks!

Kevin Char
  • 65
  • 6

1 Answers1

0

After some hair ripping frustrations and spending many hours i finally found a solution.

Forever...

https://www.npmjs.com/package/forever

For some unknown reason running the program under Forever instead of my node loop seemed to fix all the timing out problems.

Thanks for the help everyone!

Kevin Char
  • 65
  • 6