zim32 / mysql.dart

MySQL client for Dart written in Dart
BSD 3-Clause "New" or "Revised" License
67 stars 18 forks source link

Error timeout. Secure connection issue #16

Closed devnullsp closed 2 years ago

devnullsp commented 2 years ago

Using Maridb 10.6.7 win. Error timeout with simple connect. Yes, server are running and ok, i testing with DBeaver, image

zim32 commented 2 years ago

I will check using mariadb. This db was not tested

zim32 commented 2 years ago

Can you try creating connection with secure:false as parameter?

zim32 commented 2 years ago

I can reproduce error. I will check it out

zim32 commented 2 years ago

Fixed here https://github.com/zim32/mysql.dart/commit/6367ad87e3f3aca5e5c5949d6d73972b41673d53 Release 0.0.15 should work

devnullsp commented 2 years ago

hummm i think i doing wrong: image

zim32 commented 2 years ago

Ok I will add logging and then we can continue

zim32 commented 2 years ago

So I've created separete branch logging Separate branch is needed, because logging adds overhead, and I don't want any overhead in production code.

So you can add dependency as

mysql_client:
    git: https://github.com/zim32/mysql.dart.git
    ref: logging

And after dart reinstall package, you must see log messages in console.

zim32 commented 2 years ago

Please send me this messages, so I can figure out what's happening

zim32 commented 2 years ago

Ah forget. You must enable assertions to see logs. F.e. use dart --enable-asserts ...

devnullsp commented 2 years ago

Sorry for delay i confuse with git and i need to search how use

here is your log:

PS C:\PRG\DART\mysql_client_prb\bin> dart --enable-asserts run .\mysql_client_prb.dart
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:82:12)
│ #1   main (file:///C:/PRG/DART/mysql_client_prb/bin/mysql_client_prb.dart:6:40)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Establishing socket connection
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:84:12)
│ #1   <asynchronous suspension>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Socket connection established
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:162:12)
│ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:122:17)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing socket data. Current state is _MySQLConnectionState.waitInitialHandshake
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:278:12)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:166:13)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing initial handshake
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:287:12)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:166:13)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 MySQLPacketInitialHandshake:
│ 🐛
│ 🐛 authPluginDataPart1: [126, 84, 102, 37, 34, 120, 89, 55],
│ 🐛 authPluginDataPart2: [67, 46, 89, 89, 48, 38, 106, 101, 62, 69, 126, 110, 0],
│ 🐛 authPluginName: mysql_native_password,
│ 🐛 capabilityFlags: 2181036030,
│ 🐛 charset: 33,
│ 🐛 connectionID: 134,
│ 🐛 protocolVersion: 10,
│ 🐛 serverVersion: 5.5.5-10.6.7-MariaDB,
│ 🐛 statusFlags: [2, 0]
│ 🐛
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake.initiateSSL (package:mysql_client/src/mysql_client/connection.dart:292:16)
│ #1   MySQLConnection._processInitialHandshake.initiateSSL (package:mysql_client/src/mysql_client/connection.dart:291:31)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Initiating SSL connection
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
TimeoutException after 0:00:05.000000: Future not completed
zim32 commented 2 years ago

Please, pass secure: false, to createConnection and try again

zim32 commented 2 years ago

It seems that there is some problem with establishing TLS connection. Maybe firewall is blocking?

devnullsp commented 2 years ago

thanks, No its localhost, and i disable windows firewall for test and nothing Disabling secure go ok:

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:82:12)
│ #1   main (file:///C:/PRG/DART/mysql_client_prb/bin/mysql_client_prb.dart:6:40)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Establishing socket connection
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:84:12)
│ #1   <asynchronous suspension>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Socket connection established
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:162:12)
│ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:122:17)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing socket data. Current state is _MySQLConnectionState.waitInitialHandshake
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:278:12)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:166:13)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing initial handshake
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:287:12)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:166:13)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 MySQLPacketInitialHandshake:
│ 🐛
│ 🐛 authPluginDataPart1: [34, 68, 112, 40, 116, 49, 52, 82],
│ 🐛 authPluginDataPart2: [126, 69, 125, 103, 106, 97, 37, 53, 120, 34, 58, 61, 0],
│ 🐛 authPluginName: mysql_native_password,
│ 🐛 capabilityFlags: 2181036030,
│ 🐛 charset: 33,
│ 🐛 connectionID: 138,
│ 🐛 protocolVersion: 10,
│ 🐛 serverVersion: 5.5.5-10.6.7-MariaDB,
│ 🐛 statusFlags: [2, 0]
│ 🐛
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:335:12)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:166:13)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Auth plugin name is: mysql_native_password
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:357:16)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:166:13)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Native password response send
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:162:12)
│ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:122:17)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing socket data. Current state is _MySQLConnectionState.initialHandshakeResponseSend
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:222:16)
│ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:122:17)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 💡 Got OK packet. Connection established
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:162:12)
│ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:122:17)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing socket data. Current state is _MySQLConnectionState.waitingCommandResponse
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   MySQLConnection._processCommandResponse (package:mysql_client/src/mysql_client/connection.dart:388:12)
│ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:231:7)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 Processing command response packet
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
true
zim32 commented 2 years ago

Hm. I will try to test. Right now you can disable secure connection. I was thinking to make secure false by default, because it gives some network overhead and if connection is inside local network, which is in most cases true, this makes little sense

devnullsp commented 2 years ago

ok, and yes usually is local or private network. its time to start :) Thanks a lot,

bsutton commented 2 years ago

Just want to add to this that I'm having the same problems.

We are running maria db 10 within a docker container.

If I add the secure: false option then I can connect successfully.

Here is the docker-compose we are working with:

version: '3.3'

volumes:
  mysql:

services:
  mysql:
    container_name: mysql
    image: mariadb:latest
    restart: on-failure
    environment: 
      MYSQL_ROOT_PASSWORD: ${MYSQL_ADMIN_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_SCHEMA}
      TZ: ${TIME_ZONE-Australia/Melbourne}
    command: >
                 --lower-case-table-names=1
                 --bind-address=127.0.0.1
                 --default-authentication-plugin=mysql_native_password
                 --max-allowed-packet=512M
                 --innodb_buffer_pool_instances=${MYSQL_INNODB_BUFFER_POOL_INSTANCES-32}
                 --innodb_buffer_pool_chunk_size=${MYSQL_INNODB_BUFFER_POOL_CHUNK_SIZE-8M}
                 --innodb_buffer_pool_size=${MYSQL_INNODB_BUFFER_POOL_SIZE-512M}
                 --table_open_cache=${MYSQL_TABLE_OPEN_CACHE-512}
                 --max_connections=${MYSQL_MAX_CONNECTIONS-98}
                 --innodb_flush_neighbors=0
                 --innodb_fast_shutdown=2
                 --innodb_flush_log_at_trx_commit=1
                 --innodb_flush_method=fsync
                 --innodb_doublewrite=0 
                 --innodb_use_native_aio=0
                 --innodb_read_io_threads=10
                 --innodb_write_io_threads=10
                 --slow_query_log_file=/tmp/mysql-slow.log --long-query-time=1
                 --slow_query_log

    volumes:
      - mysql:/var/lib/mysql
    network_mode: "host"
    logging:
      driver: "journals"
bsutton commented 2 years ago

I'm just concerned that you have marked this as a workaround based on turning off the secure option. To be clear, I wouldn't view this as a workaround but a serious security hole.

zim32 commented 2 years ago

It just means that issue can be temporary fixed f.e. when developing in dev environment or when mysql server and application is inside trusted network.

I will fix this

zim32 commented 2 years ago

Good day. Can you try latest release? Maybe it will fix this issue.