Skip to content

Protocol.end error #1067

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

Closed
anas-abusall opened this issue Apr 29, 2015 · 12 comments
Closed

Protocol.end error #1067

anas-abusall opened this issue Apr 29, 2015 · 12 comments
Assignees
Labels

Comments

@anas-abusall
Copy link

Hi there,
I have a script that is connected remotely to a server with mysql DB.
The code is working well and makes my queries perfectly but after a while i get this error:

Error: Connection lost: The server closed the connection.
    at Protocol.end (/root/node_modules/mysql/lib/protocol/Protocol.js:103:13)
    at Socket.<anonymous> (/root/node_modules/mysql/lib/Connection.js:98:28)
    at Socket.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

How can i bypass this problem?
Regards
Anas

@dougwilson
Copy link
Member

There really isn't an issue here. You could ignore the error or you could call connection.end() prior to your MySQL closing the connection for you. This could be triggered from various variables on your MySQL server, but is most likely from the wait_timeout variable on your remote MySQL server. You can always bump it up, but you'll have to call connection.end() on your client prior to that timeout.

@dougwilson dougwilson self-assigned this Apr 29, 2015
@AdriVanHoudt
Copy link

I also get this error but my wait_timeout is 28800 (default) which is 20 days right? And this happens before those 20 days.
Exact stacktrace

Error: Connection lost: The server closed the connection.
at Protocol.end (/home/***/node_modules/mysql/lib/protocol/Protocol.js:103:13)
at Socket.<anonymous> (/home/***/node_modules/mysql/lib/Connection.js:98:28)
at Socket.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickDomainCallback (node.js:492:13)
    --------------------
    at Protocol._enqueue (/home/***/node_modules/mysql/lib/protocol/Protocol.js:135:48)
    at Protocol.handshake (/home/***/node_modules/mysql/lib/protocol/Protocol.js:52:41)
    at PoolConnection.connect (/home/***/node_modules/mysql/lib/Connection.js:119:18)
    at Pool.getConnection (/home/***/node_modules/mysql/lib/Pool.js:45:23)
    at Object.exports.register (/home/***/node_modules/hapi-plugin-mysql/lib/index.js:42:24)
    at /home/***/node_modules/hapi/lib/plugin.js:242:14
    at iterate (/home/***/node_modules/hapi/node_modules/items/lib/index.js:35:13)
    at done (/home/***/node_modules/hapi/node_modules/items/lib/index.js:27:25)
    at Object.exports.register (/home/***/node_modules/lout/lib/index.js:95:5)
    at /home/***/node_modules/hapi/lib/plugin.js:242:14

@sidorares
Copy link
Member

isn't 28800 == 8 hours?

@sidorares
Copy link
Member

might be typo, 1728000 is 20 days indeed

@AdriVanHoudt
Copy link

Ok yeah 8 hours woops. Is there some guideline as to changing this variable? Can I just bump it to max or...?

@AdriVanHoudt
Copy link

Shouldn't node-mysql catch this error? If it appears destroy the connection and create a new one and return the new one? (I'm also using a connection pool)

@sidorares
Copy link
Member

Yes, with pool error is not propagated up by default because pool listens for error events of each connection. Do you see different behaviour?

@AdriVanHoudt
Copy link

Well I still get the above error so yes the behaviour I get is different then I described in my previous comment. Or do you mean different when setting the wait_timeout higher?

@dougwilson
Copy link
Member

@AdriVanHoudt can you open a new issue with that stack trace and some code to reproduce? It's likely a different issue (if even an issue vs. expected behavior) and we can discuss there :)

@AdriVanHoudt
Copy link

@dougwilson sure, I don't have a project to reproduce this yet but I'll see what I can do

@dougwilson
Copy link
Member

No problem :) I'd be happy to take a look into this :)

@AdriVanHoudt
Copy link

thanks, made a new issue here #1070

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

No branches or pull requests

4 participants