blackbeam/mysql_async

Got an error reading communication packets

nbari opened this issue · 1 comments

nbari commented

When disconnection/closing the connection from the server-side I get this warning:

 [Warning] Aborted connection 14 to db: 'unconnected' user: 'root' host: '172.18.0.2' (Got an error reading communication packets)

At first, I thought it could be because of the HAProxy in front but after testing with the native MySQL client it works as expected, please here find a way to reproduce this behavior here: https://github.com/nbari/haproxy-mariadb

You can reproduce the same behavior with the app mycli

mycli -h 127.0.0.1 --port 3306 -uroot --pass secret

or with this rust example

use mysql_async::prelude::*;

#[tokio::main]
async fn main() {
    let opts = mysql_async::OptsBuilder::default()
        .user(Some("root"))
        .pass(Some("secret"))
        .db_name(Some("world"))
        .ip_or_hostname(String::from("127.0.0.1"))
        .tcp_port(3306)
        .stmt_cache_size(0);
    let mut conn = mysql_async::Conn::new(opts).await.unwrap();

    let version: Option<String> = conn.query_first("SELECT VERSION()").await.unwrap();
    drop(conn);
    println!("{}", version.unwrap());
}
nbari commented

From https://mariadb.com/kb/en/com_quit/:

int<1> 0x01 : COM_QUIT Header

I found here:

self.write_command_data(Command::COM_QUIT, &[]).await?;

Tried already with something like

 self.write_command_data(Command::COM_QUIT, &[1]).await?;

But no luck, any ideas?