Fatal `Packets out of order` exception using `mysql` lib connecting to `mysql2` proxy
See original GitHub issueUsing the example proxy, when making a client connection using the mysql
library, a fatal exception occurs and the connection is lost.
Client example:
const knex = require("knex")({
client: "mysql",
connection: {
host: "127.0.0.1",
port: 4000,
user: "***",
password: "***",
database: "***"
},
});
knex.raw("select 1").then(console.log);
The server exception:
[nodemon] starting `node index.js`
connection
Warning: got packets out of order. Expected 3 but received 0
proxying query: select 1
events.js:298
throw er; // Unhandled 'error' event
^
Error: Connection lost: The server closed the connection.
at Socket.<anonymous> (/foo/node_modules/mysql2/lib/connection.js:91:31)
at Socket.emit (events.js:321:20)
at TCP.<anonymous> (net.js:668:12)
Emitted 'error' event on Connection instance at:
at Connection._notifyError (/foo/node_modules/mysql2/lib/connection.js:221:12)
at Socket.<anonymous> (/foo/node_modules/mysql2/lib/connection.js:97:12)
at Socket.emit (events.js:321:20)
at TCP.<anonymous> (net.js:668:12) {
fatal: true,
code: 'PROTOCOL_CONNECTION_LOST'
}
Client exception:
(node:1521) UnhandledPromiseRejectionWarning: Error: Packets out of order. Got: 4 Expected: 1
NOTE: This does not occur when using mysql2
as the client library.
Please let me know if I can provide any further detail to help debug.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
got packets out of order. Expected 1 but received 28 · Issue ...
I am trying to create a MySQL server using node-mysql2, ... Fatal Packets out of order exception using mysql lib connecting to mysql2...
Read more >4.22 Troubleshooting Problems Connecting to MySQL
You can fix this by setting up an account for the combination of client host name and user name that you are using...
Read more >"MySQL server has gone away" error - Solution(s)
The MySQL server has gone away error, which means that the MySQL server (mysqld) timed out and closed the connection. By default, MySQL...
Read more >Fix "MySQL server has gone away", "packets out of order" ...
The issue might be due to the fact that the server timed out and closed the connection. Check the wait_timeout MySQL variable value...
Read more >Error: Packets out of order. Got: 0 Expected: 3 - mysql
I'd suspect the mysql-nodejs version isn't resetting the expected packet count on re-connection. In a test environment you can reduce the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dtikhonov-iex see https://github.com/sidorares/node-mysql2/issues/528#issuecomment-944949065 also.
Thanks for this workaround, @MartinGassner. I was hoping that the bug was something obvious (and I spent some time reading the code trying to figure it out), but from @sidorares’s description it seems that this is a structural issue.