rodrigogs / mysql-events

A node package that watches a MySQL database and runs callbacks on matched events.
BSD 3-Clause "New" or "Revised" License
136 stars 52 forks source link

PROTOCOL_CONNECTION_LOST #11

Closed MInesGomes closed 5 years ago

MInesGomes commented 5 years ago

Hi @rodrigogs

After around 2 days it loses the connection with the server.

Suggestion: pooled MySQL connections like here https://fearby.com/article/how-to-setup-pooled-mysql-connections-in-node-js-that-dont-disconnect/

Or Change to mysql2 ?

(I am using pm2 to manage the script)

All the error detail: { Error: Cannot enqueue Query after fatal error. at Protocol._validateEnqueue (/home/timmeh55/nmsSocket/node_modules/mysql/lib/protocol/Protocol.js:200:16) at Protocol._enqueue (/home/timmeh55/nmsSocket/node_modules/mysql/lib/protocol/Protocol.js:138:13) at Connection.query (/.../nmsSocket/node_modules/mysql/lib/Connection.js:200:25) at ZongJi._fetchTableInfo (/home/timmeh55/nmsSocket/node_modules/@rodrigogs/zongji/index.js:203:23) at Binlog._callback (/../nmsSocket/node_modules/@rodrigogs/zongji/index.js:251:18) at Binlog.BinlogHeader (/home/timmeh55/nmsSocket/node_modules/@rodrigogs/zongji/lib/sequence/binlog.js:43:22) at Protocol._parsePacket (/home/timmeh55/nmsSocket/node_modules/mysql/lib/protocol/Protocol.js:278:23) at Parser.write (/.../nmsSocket/node_modules/mysql/lib/protocol/Parser.js:76:12) at Protocol.write (/.../nmsSocket/node_modules/mysql/lib/protocol/Protocol.js:38:16) at Socket. (/.../nmsSocket/node_modules/mysql/lib/Connection.js:91:28) code: 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR', fatal: false } { Error: Connection lost: The server closed the connection. at Protocol.end (/home/timmeh55/nmsSocket/node_modules/mysql/lib/protocol/Protocol.js:112:13) at Socket. (/.../nmsSocket/node_modules/mysql/lib/Connection.js:97:28) at Socket. (/.../nmsSocket/node_modules/mysql/lib/Connection.js:502:10) at Socket.emit (events.js:187:15) at endReadableNT (_stream_readable.js:1094:12) at args.(anonymous function) (/usr/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29) at process._tickCallback (internal/process/next_tick.js:63:19) fatal: true, code: 'PROTOCOL_CONNECTION_LOST' }

rodrigogs commented 5 years ago

You should be able to use a connection pool with mysql-events. Did you try it?

Sorry for the delay, I was traveling.

rodrigogs commented 5 years ago

Hmmm... now reading the code I noticed that maybe connnection pool will not work properly. I'm willing to test and fix it(if needed) during this week. I'd be glad if you could help me to test it.

MInesGomes commented 5 years ago

Thank you Rodrigo,

I will be glad to help testing

Kind Regards,

Ines Gomes https://www.linkedin.com/in/minesgomes/ mobileGoTop@gmail.com mailto:mobileGoTop@gmail.com

On 16 Apr 2019, at 20:32, Rodrigo Gomes da Silva notifications@github.com wrote:

Hmmm... now reading the code I noticed that maybe connnection pool will not work properly. I'm willing to test and fix it(if needed) during this week. I'd be glad if you could help me to test it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rodrigogs/mysql-events/issues/11#issuecomment-483792047, or mute the thread https://github.com/notifications/unsubscribe-auth/ADGQHsSyw6OqoY_DBIXfmu65R8ipTVqeks5vhhclgaJpZM4cp0Zz.

rodrigogs commented 5 years ago

Sorry @Entrecampos, I'm totally out of time these days. It will take some more time for me to be able to maintain this repository again.

MInesGomes commented 5 years ago

Thanks for your reply Rodrigo,

On Thu, 25 Apr 2019, 21:32 Rodrigo Gomes da Silva, notifications@github.com wrote:

Sorry @Entrecampos https://github.com/Entrecampos, I'm totally out of time these days. It will take some more time for me to be able to maintain this repository again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rodrigogs/mysql-events/issues/11#issuecomment-486808253, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYZAHQKZWYV6S22FFMCAVTPSIBMFANCNFSM4HFHIZZQ .

lemnisk8 commented 5 years ago

@Entrecampos : created a pull request for pool connections... might be helpful... @rodrigogs : Thanks for your work on this project...

rodrigogs commented 5 years ago

@Entrecampos just released a fix https://github.com/rodrigogs/mysql-events/releases/tag/0.6.0

rodrigogs commented 5 years ago

Although it should solve the problem, I also use to restart the mysql-events process from time to time to prevent protocol errors and leaks... it works very well

rodrigogs commented 5 years ago

@lemnisk8 Sorry for not accepting your PR... but I was already working on this, and you didnt used project's eslint and didnt wrote testes :/