mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.27k stars 2.52k forks source link

ER_ACCESS_DENIED_ERROR: Proxy ERROR:connect to backend error #2274

Closed huturen closed 4 years ago

huturen commented 4 years ago

The error stack:

Error: ER_ACCESS_DENIED_ERROR:  Proxy ERROR:connect to backend error
    at Handshake.Sequence._packetToError (~/web/lag/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (~/web/lag/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (~/web/lag/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (~/web/lag/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (~/web/lag/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (~/web/lag/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (~/web/lag/node_modules/mysql/lib/Connection.js:91:28)
    at Socket.<anonymous> (~/web/lag/node_modules/mysql/lib/Connection.js:525:10)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    --------------------
    at Protocol._enqueue (~/web/lag/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (~/web/lag/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at PoolConnection.connect (~/web/lag/node_modules/mysql/lib/Connection.js:119:18)
    at Pool.getConnection (~/web/lag/node_modules/mysql/lib/Pool.js:48:16)
    at Pool.query (~/web/lag/node_modules/mysql/lib/Pool.js:202:8)
    at Promise (~/web/lag/lib/mysql/index.js:22:23)
    at new Promise (<anonymous>)
    at Mysql.execute (~/web/lag/lib/mysql/index.js:21:16)
    at AMPage.saveAmsCompeteData (~/web/lag/dao/amdata.js:42:42)
    at process._tickCallback (internal/process/next_tick.js:68:7)

It seems that the connection was not closed or broken, because the other sqls after the caught error were executed correctly in the same connection:

  1. sql INSERT INTO tbx (day,account) VALUES (20190927, 123) ON DUPLICATE KEY UPDATE day = 20190927,account = 123 was executed successfully.
  2. sql INSERT INTO tbx (day,account) VALUES (20190927,456) ON DUPLICATE KEY UPDATE day = 20190927,account = 456 caught error: ER_ACCESS_DENIED_ERROR: Proxy ERROR:connect to backend error
  3. sql INSERT INTO tbx (day,account) VALUES (20190927,789) ON DUPLICATE KEY UPDATE day = 20190927,account = 789 was executed successfully.

The three steps above are all in the same connection.

codes like below:

const mysql = require('mysql');
const pool = new mysql.createPool({
    "host":"192.168.10.34",
    "port":3306,
    "database":"lag",
    "user":"laguser",
    "password":"lagpassword",
    "multipleStatements":true    
});
...
pool.query(...)
dougwilson commented 4 years ago

Hi @huturen since you are using pool.query, you are not always using the same connection, which is why it continues to work after the error - because the pool will reconnect.

The error itself is coming from your MySQL server and this module is just surfacing the error. You'll need to consult whatever proxy software you are using to determine what that error means (sorry, I have never seen that error before).

If you think it's an issue with this module, let us know.

huturen commented 4 years ago

I get it now, thanks!