Saturday, 29 April 2017

SQL Error: ER_CONCOUNT_ERROR: Too many connection

I'm making a Discord Bot which is comprised of Discord.js which I have some SQL to store commands people make. After a while of leaving the bot on I get this error Error: ER_CON_COUNT_ERROR: Too mant connections and it crashes the bot. This is the full error:

C:\Users\Jake\Desktop\MyBot\app.js:112
  if (error) throw error;
           ^

Error: ER_CON_COUNT_ERROR: Too many connections
  at Handshake.Sequence._packetToError (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14)
  at Handshake.ErrorPacket (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\sequences\Handshake.js:103:18)
  at Protocol._parsePacket (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\Protocol.js:280:23)
  at Parser.write (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\Parser.js:75:12)
  at Protocol.write (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\Protocol.js:39:16)
  at Socket.<anonymous> (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\Connection.js:103:28)
  at emitOne (events.js:96:13)
  at Socket.emit (events.js:191:7)
  at readableAddChunk (_stream_readable.js:178:18)
  at Socket.Readable.push (_stream_readable.js:136:10)
--------------------
  at Protocol._enqueue (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\Protocol.js:141:48)
  at Protocol.handshake (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\protocol\Protocol.js:52:41)
  at Connection.connect (C:\Users\Jake\Desktop\MyBot\node_modules\mysql\lib\Connection.js:130:18)
  at Client.client.on (C:\Users\Jake\Desktop\MyBot\app.js:100:14)
  at emitOne (events.js:101:20)
  at Client.emit (events.js:191:7)
  at MessageCreateHandler.handle (C:\Users\Jake\Desktop\MyBot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
  at WebSocketPacketManager.handle (C:\Users\Jake\Desktop\MyBot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:120:65)
  at WebSocketManager.eventMessage (C:\Users\Jake\Desktop\MyBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:273:31)
  at WebSocket.onMessage (C:\Users\Jake\Desktop\MyBot\node_modules\ws\lib\WebSocket.js:442:14)

I'm not sure on what this means but the code around the error which throw this is:

  connection.query("SELECT * FROM commands WHERE guildid = '" + message.guild.id + "'", info, function(error, theCommands) {
    if (error) throw error;

    if (theCommands.length) {
      theCommands.forEach(eachCommand => {
        if (message.content == eachCommand.commandname) return message.channel.sendMessage(eachCommand.commandreply);
      });
    };
  });



via Rusty

No comments:

Post a Comment