New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection lost: The server closed the connection, when using the pool #398

Closed
kibs opened this Issue Feb 22, 2013 · 10 comments

Comments

Projects
None yet
4 participants
@kibs

kibs commented Feb 22, 2013

Hi,

I am using the pool for getting connections, as I had problems with my MySQL closing the connection after some time of inactivity.

As I read the documentation, the pool should handle closed connections automatically, but I still get the following error

events.js:71
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Connection lost: The server closed the connection.

Any suggestions?

@dresende

This comment has been minimized.

Show comment
Hide comment
@dresende

dresende Feb 22, 2013

Collaborator

Are you disposing the connection after each batch of queries?

Collaborator

dresende commented Feb 22, 2013

Are you disposing the connection after each batch of queries?

@kibs

This comment has been minimized.

Show comment
Hide comment
@kibs

kibs Feb 22, 2013

calling connection.end() like the README suggests

kibs commented Feb 22, 2013

calling connection.end() like the README suggests

@dresende

This comment has been minimized.

Show comment
Hide comment
@dresende

dresende Feb 23, 2013

Collaborator

It seems the error event is triggered and you're not listening it. I know there are some database servers with a very small timeout and the server might be dropping connection even when using Pool. I don't know exactly if that's the problem, it's very vague. Do you have more information about it? Like when it happens, after how much time, what server are you connecting to, ...

Collaborator

dresende commented Feb 23, 2013

It seems the error event is triggered and you're not listening it. I know there are some database servers with a very small timeout and the server might be dropping connection even when using Pool. I don't know exactly if that's the problem, it's very vague. Do you have more information about it? Like when it happens, after how much time, what server are you connecting to, ...

@kibs

This comment has been minimized.

Show comment
Hide comment
@kibs

kibs Feb 23, 2013

I think my server has a small timeout, it happens maybe 30 seconds after last query. For now, I destroy the connection after each set of queries, this works, but is not the best setup.

What I think I am missing, is some sort of event on the pool when a connection disconnects, so I can catch the error and gracefully ignore it.

kibs commented Feb 23, 2013

I think my server has a small timeout, it happens maybe 30 seconds after last query. For now, I destroy the connection after each set of queries, this works, but is not the best setup.

What I think I am missing, is some sort of event on the pool when a connection disconnects, so I can catch the error and gracefully ignore it.

@mikermcneil

This comment has been minimized.

Show comment
Hide comment
@mikermcneil

mikermcneil Mar 2, 2013

I'm having the same issue on 2.0.0-alpha7 when using pools. After a few seconds, it throws:


events.js:71
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Connection lost: The server closed the connection.
    at Protocol.end (............/node_modules/mysql/lib/protocol/Protocol.js:72:13)
    at Socket.onend (stream.js:66:10)
    at Socket.EventEmitter.emit (events.js:126:20)
    at TCP.onread (net.js:418:51)

mikermcneil commented Mar 2, 2013

I'm having the same issue on 2.0.0-alpha7 when using pools. After a few seconds, it throws:


events.js:71
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Connection lost: The server closed the connection.
    at Protocol.end (............/node_modules/mysql/lib/protocol/Protocol.js:72:13)
    at Socket.onend (stream.js:66:10)
    at Socket.EventEmitter.emit (events.js:126:20)
    at TCP.onread (net.js:418:51)

@dresende

This comment has been minimized.

Show comment
Hide comment
@dresende

dresende Mar 5, 2013

Collaborator

I'm going to change the global wait_timeout variable and see what happens..

Collaborator

dresende commented Mar 5, 2013

I'm going to change the global wait_timeout variable and see what happens..

@dresende

This comment has been minimized.

Show comment
Hide comment
@dresende

dresende Mar 5, 2013

Collaborator

I've just made a small change to the Pool, please test the latest commit.

Collaborator

dresende commented Mar 5, 2013

I've just made a small change to the Pool, please test the latest commit.

@dresende

This comment has been minimized.

Show comment
Hide comment
@dresende

dresende Mar 12, 2013

Collaborator

Marking as fixed for next release if nobody claims it doesn't work.

Collaborator

dresende commented Mar 12, 2013

Marking as fixed for next release if nobody claims it doesn't work.

@dresende dresende closed this Mar 12, 2013

@atimb

This comment has been minimized.

Show comment
Hide comment
@atimb

atimb Apr 19, 2013

We have the same crashes because the unhandled pool error event, and I have reviewed your fix and it should work fine. My only question is that why is not a new version is released on npm? This is a pretty critical fix.

atimb commented Apr 19, 2013

We have the same crashes because the unhandled pool error event, and I have reviewed your fix and it should work fine. My only question is that why is not a new version is released on npm? This is a pretty critical fix.

@mikermcneil

This comment has been minimized.

Show comment
Hide comment
@mikermcneil

mikermcneil Apr 19, 2013

@atimb agreed! I'd love to depend on this version in https://github.com/balderdashy/sails-mysql

mikermcneil commented Apr 19, 2013

@atimb agreed! I'd love to depend on this version in https://github.com/balderdashy/sails-mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment