Skip to content
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

invalidProtocolVersion(255) when trying to connect to MySQL on Ubuntu #91

Closed
bporter95 opened this issue Feb 3, 2023 · 3 comments · Fixed by #95
Closed

invalidProtocolVersion(255) when trying to connect to MySQL on Ubuntu #91

bporter95 opened this issue Feb 3, 2023 · 3 comments · Fixed by #95
Assignees
Labels
bug Something isn't working

Comments

@bporter95
Copy link

Describe the bug

When trying to connect to MySQL from Vapor running on Ubuntu, I am receiving the following error:
invalidProtocolVersion(255)

Meanwhile, I have no issues with connecting when running Vapor on my Mac locally

Environment

I am running Vapor in a Docker Container on an Ubuntu 22 server. I have also tried running vapor outside of docker using the cli.
I am running MySQL 8.0.32-0ubuntu0.22.04.2

  • Vapor Framework version:
    • Vapor: 4.69.1
    • Fluent 4.6.0
    • Fluent MySQL Driver 4.2.0
  • OS version: Ubuntu 22.04.2
@bporter95 bporter95 added the bug Something isn't working label Feb 3, 2023
@T2Je
Copy link

T2Je commented Feb 28, 2023

Did you find any solution?

@bporter95
Copy link
Author

In my case, it ended up being a MySQL credentials error (nothing related to a bug in Fluent)

@gwynne
Copy link
Member

gwynne commented Mar 9, 2023

Hey, I wanted to follow up on this quickly - while it's true that the immediate cause of the problem was on the server end, Fluent should not have been reporting that particular, very unhelpful error. This particular symptom occurs when the server sends an ERR_Packet, which starts with an 0xff (255) marker byte, immediately upon connection, instead of the expected HandshakeV10 greeting, whose first byte is expected to be the advertised protocol version. It's is an entirely valid thing for the server to do, but the wire protocol implementation in MySQLNIO currently mishandles it by immediately rejecting the 255 value where it expected to find a protocol version number (specifically, 10), rather than checking to see if the packet represents an error. As a result, the error message the server sent is lost.

A large-scale rewrite of MySQLNIO to address this and dozens of other issues is currently in progress, hopefully I'll have it ready for at least a preview soon.

@gwynne gwynne transferred this issue from vapor/fluent-mysql-driver Mar 9, 2023
@gwynne gwynne reopened this Mar 9, 2023
@gwynne gwynne closed this as completed in #95 May 9, 2023
gwynne added a commit that referenced this issue May 9, 2023
* Update package support files (dockerignore, readme, CI workflows)
* Minimal code cleanup - replace `fatalError()`s and `assert()`s with thrown errors, add escapes in comments so Xcode's inline formatting doesn't choke, add `any` to existential usage, other very minor tweaks.
* Fix the "server sends error packet when nothing else is going on causes crash" problem - fixes #87
* Add fix for the bad protocol version bug - fixes #91
* Fix the tests bug that causes problems with the `foos` table still existing when the integration tests for FluentMySQLDriver run.
* Work around weird deadlock on Linux
* Remove many unneeded !s from try!s in tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants