-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Java app using MariaDB 2.1.2 driver fails to connect #4603
Comments
Just to add a little bit more of detail to this issue, it breaks in this commit: fa42f53 Reproduction case: package main
import (
"crypto/sha1"
"encoding/hex"
"fmt"
"log"
"strings"
"time"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqltypes"
)
func main() {
auth := mysql.NewAuthServerStatic()
pwd := nativePassword("")
auth.Entries["root"] = []*mysql.AuthServerStaticEntry{{
MysqlNativePassword: pwd,
Password: pwd,
}}
l, err := mysql.NewListener("tcp", ":3306", auth, new(handler), 10*time.Minute, 10*time.Minute)
if err != nil {
log.Fatal(err)
}
l.Accept()
}
type handler struct{}
func (*handler) NewConnection(c *mysql.Conn) {
log.Println("CONNECTION OPENED")
}
func (*handler) ConnectionClosed(c *mysql.Conn) {
log.Println("CONNECTION CLOSED")
}
func (*handler) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes.Result) error) error {
log.Println("QUERY: " + query)
return nil
}
func (*handler) WarningCount(c *mysql.Conn) uint16 { return 0 }
func nativePassword(password string) string {
if len(password) == 0 {
return ""
}
// native = sha1(sha1(password))
hash := sha1.New()
hash.Write([]byte(password))
s1 := hash.Sum(nil)
hash.Reset()
hash.Write(s1)
s2 := hash.Sum(nil)
s := strings.ToUpper(hex.EncodeToString(s2))
return fmt.Sprintf("*%s", s)
} Scala app to trigger this: import java.sql._
object Main extends App {
val connection = DriverManager.getConnection(
s"jdbc:mariadb://0.0.0.0:3306",
"root",
""
)
val stmt: PreparedStatement = connection.prepareStatement("SHOW TABLES")
val rs = stmt.executeQuery
rs.close()
stmt.close()
} |
I believe it's because you're using the prepared statement protocol, which is not yet supported by vitess. |
Exact same code switching MariaDB driver to MySQL driver works, so it must be something else.
…On 30 Apr 2019, 19:17 +0200, Sugu Sougoumarane ***@***.***>, wrote:
I believe it's because you're using the prepared statement protocol, which is not yet supported by vitess.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yeah. This looks like a handshake error. We'll need to add some instrumentation here: https://github.com/vitessio/vitess/blob/master/go/mysql/server.go#L732. It's not receiving the number of bytes its' expecting. |
#4897 seems to have fixed this specific problem; however, there are other issues with the mariadb connector, for which I will log a separate issue. |
I'm trying to connect an off the shelf app (prisma.io) to Vitess, but it is failing on the client handshake. It is using
mariadb-java-client 2.1.2
to connect. I'm not a Java user, so I don't know how to test/debug this any further.There is already interest in using Vitess with Prisma in this issue: prisma/prisma#2451
vtgate logs
Java client logs
The text was updated successfully, but these errors were encountered: