zim32 / mysql.dart

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

MySQLServerException [1159]: Got timeout reading communication packets #26

Closed MHShetty closed 2 years ago

MHShetty commented 2 years ago

Here are the logs that I testing the main branch -

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MySQLServerException [1159]: Got timeout reading communication packets
#0      MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:201:9)
#1      MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:113:17)
#2      MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:110:42)
#3      _rootRunUnary (dart:async/zone.dart:1434:47)
#4      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#9      _StreamController._add (dart:async/stream_controller.dart:648:7)
#10     _StreamController.add (dart:async/stream_controller.dart:596:5)
#11     _Socket._onData (dart:io-patch/socket_patch.dart:2314:41)
#12     _rootRunUnary (dart:async/zone.dart:1442:13)
#13     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#14     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#15     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#16     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#17     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#18     _StreamController._add (dart:async/stream_controller.dart:648:7)
#19     _StreamController.add (dart:async/stream_controller.dart:596:5)
#20     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1839:33)
#21     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#22     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#23     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

flutter: TimeoutException
flutter: TimeoutException after 0:00:30.000000: Future not completed
flutter: Isconnected: false
Lost connection to device.

I'll share the logs from the logging branch soon. Please do let me know if any additional information is required apart from that.

Thanks for your valuable time @zim32!

MHShetty commented 2 years ago

Hi @zim32,

Here are the required logs:

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Debug service listening on ws://127.0.0.1:54375/3uiazfbk5Us=/ws
Syncing files to device Windows...
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:83:12)
flutter: │ #1   init (package:test_project/sql.dart:11:39)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Establishing socket connection
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:83:12)
flutter: │ #1   init (package:test_project/sql.dart:11:39)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Establishing socket connection
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: Isconnected: false
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:85:12)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Socket connection established
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:85:12)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Socket connection established
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:123:17)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.waitInitialHandshake
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:279:12)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:167:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing initial handshake
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:288:12)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:167:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 MySQLPacketInitialHandshake:
flutter: │ 🐛 
flutter: │ 🐛 authPluginDataPart1: [67, 75, 61, 79, 101, 84, 124, 12],
flutter: │ 🐛 authPluginDataPart2: [20, 10, 70, 40, 7, 68, 23, 29, 49, 13, 91, 29, 0],
flutter: │ 🐛 authPluginName: caching_sha2_password,
flutter: │ 🐛 capabilityFlags: 3758096383,
flutter: │ 🐛 charset: 255,
flutter: │ 🐛 connectionID: 48,
flutter: │ 🐛 protocolVersion: 10,
flutter: │ 🐛 serverVersion: 8.0.29,
flutter: │ 🐛 statusFlags: [2, 0]
flutter: │ 🐛 
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:336:12)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:167:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Auth plugin name is: caching_sha2_password
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:380:16)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:167:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Caching sha2 password response send
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:123:17)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.initialHandshakeResponseSend
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:212:16)
flutter: │ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:123:17)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ ⛔ Skipping invalid packet: [2, 0, 0, 2, 1, 4]
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:123:17)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.initialHandshakeResponseSend
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MySQLServerException: Got timeout reading communication packets
#0      MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:219:9)
#1      MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:123:17)
#2      MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:120:42)
#3      _rootRunUnary (dart:async/zone.dart:1434:47)
#4      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#9      _StreamController._add (dart:async/stream_controller.dart:648:7)
#10     _StreamController.add (dart:async/stream_controller.dart:596:5)
#11     _Socket._onData (dart:io-patch/socket_patch.dart:2314:41)
#12     _rootRunUnary (dart:async/zone.dart:1442:13)
#13     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#14     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#15     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#16     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#17     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#18     _StreamController._add (dart:async/stream_controller.dart:648:7)
#19     _StreamController.add (dart:async/stream_controller.dart:596:5)
#20     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1839:33)
#21     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#22     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#23     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

Btw, really liked the effective presentation for your logs. Good work @zim32! 👏

zim32 commented 2 years ago

Ok let's go deeper. On logging branch, open lib/src/mysql_client/connection.dart file and change

Find line at the top: final loggingLevel = Level.debug;

And change it to: final loggingLevel = Level.verbose;

Then test again and copy-paste logs please.

zim32 commented 2 years ago

Sorrty this was for another issue

MHShetty commented 2 years ago

Hi @zim32,

With the latest changes pushed to the repository, I no longer get the timeout related issue now.

The connection probably just stops after receiving a unsupported generic packet, unlike how it earlier used to show a timeout related message or error.

zim32 commented 2 years ago

So here we returns to your original problem?

zim32 commented 2 years ago

This invalid packet type is very strange. I can not identify what is the packet with type 0x1. This is not ok, not err, not eof packet...

MHShetty commented 2 years ago

So here we returns to your original problem?

Still need to figure that out.. I suppose its some configuration related issue with MySQL on my end. Will add more information to this thread once that's cleared.

MHShetty commented 2 years ago

This invalid packet type is very strange. I can not identify what is the packet with type 0x1. This is not ok, not err, not eof packet...

Even I'm kind of confused, couldn't find anything related to it in the docs of MySQL. Could be an issue with the implementation of MySQL 8 server (not really sure though).

zim32 commented 2 years ago

Can you try to secure: false again. Just to check

MHShetty commented 2 years ago

Hi @zim32,

I'm using already using secure: false, so isn't really an issue that way.

MHShetty commented 2 years ago

I'll just revert back to version 0.0.19 for testing this issue until we figure this out entirely.

zim32 commented 2 years ago

What we will do next is try to setup verbose logging to see raw bytes. We.have problem that nothing changes when you enable verbose level. Do tou now what can be the cause?

MHShetty commented 2 years ago

Hi @zim32,

Got some good news. This issue specifically seems to have got resolved in 0.0.19, after I manually try to connect to the database via command line.

Not really sure if the library needs to do something here (maybe request starting something or anything related to it) before trying to create a connection, but it surely does connect for now.

I'll try connecting with the latest version of the library and get back with some more information asap.

MHShetty commented 2 years ago

Hi @zim32,

It's working as expected on the latest version too.

First trying to manually connect to MySQL server from command line and then trying to connect from the app somehow seems to resolve the issue.

The only thing that we need probably to check now is that, whether the library expected to do something before/while trying to connect to MySQL (like starting something up or requesting the server that has already started to do so). Other than that, I think that this issue is safe to close.

Thanks a lot for coming up with this library and for providing your valuable time and assistance @zim32!

zim32 commented 2 years ago

This is strange. I thinks someone already talked about it. After restarting your app it may still not work and require connecting from console first. Can not event imagine what's going on

MHShetty commented 2 years ago

Yeah actually. Ideally it should get connected since the server is already on.

Please do let me know if you need any help with getting more information or probably with some testing on this issue. I should be able to reproduce this issue on restarting my computer system.

zim32 commented 2 years ago

I need to setup flutter app and test it

zim32 commented 2 years ago

So I setup simple flutter app. I have no problems with connecting to mysql servers, both mariadb and mysql.

Here is code:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // create connection
  final conn = await MySQLConnection.createConnection(
    host: "127.0.0.1",
    port: 3306,
    userName: "root",
    password: "****",
    databaseName: "zim32_testdb", // optional
    secure: false,
  );

  await conn.connect();
  // make query
  final result = await conn.execute("SELECT VERSION()");
  // print some result data
  print(result.rows.first.colAt(0));

  runApp(const MyApp());
}

Prints: I/flutter (27536): 10.3.13-MariaDB-1:10.3.13+maria~bionic

I connect my phone to laptop by USB cable. Setup port forwarding in Chrome devices tab. My system is linux. MySQL servers are inside docker containers

MHShetty commented 2 years ago

Hey @zim32,

I'm really uncertain if this is an issue with MySQL or library, but I'm persistently able to reproduce it. The invalid packets issue still seems to persist unfortunately (both with secure disabled or default enabled).

Here are the latest logs (with secure enabled):

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Debug service listening on ws://127.0.0.1:50248/PnzuRO6Gvvo=/ws
Syncing files to device Windows...
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:83:12)
flutter: │ #1   init (package:test_project/sql.dart:11:39)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Establishing socket connection
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: Isconnected: false
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection.createConnection (package:mysql_client/src/mysql_client/connection.dart:85:12)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Socket connection established
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection.connect.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:123:17)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.waitInitialHandshake
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:280:12)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:167:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing initial handshake
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: Buffer: [10, 56, 46, 48, 46, 50, 57, 0, 46, 0, 0, 0, 122, 102, 2, 50, 8, 12, 71, 23, 0, 255, 255, 255, 2, 0, 255, 223, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 26, 52, 106, 107, 49, 116, 17, 9, 70, 111, 13, 0, 99, 97, 99, 104, 105, 110, 103, 95, 115, 104, 97, 50, 95, 112, 97, 115, 115, 119, 111, 114, 100, 0]
flutter: byteData: TypedDataView(cid: 152)
flutter: protocolVersion: 10
flutter: serverVersion: 8.0.29
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:289:12)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:167:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 MySQLPacketInitialHandshake:
flutter: │ 🐛 
flutter: │ 🐛 authPluginDataPart1: [122, 102, 2, 50, 8, 12, 71, 23],
flutter: │ 🐛 authPluginDataPart2: [17, 26, 52, 106, 107, 49, 116, 17, 9, 70, 111, 13, 0],
flutter: │ 🐛 authPluginName: caching_sha2_password,
flutter: │ 🐛 capabilityFlags: 3758096383,
flutter: │ 🐛 charset: 255,
flutter: │ 🐛 connectionID: 46,
flutter: │ 🐛 protocolVersion: 10,
flutter: │ 🐛 serverVersion: 8.0.29,
flutter: │ 🐛 statusFlags: [2, 0]
flutter: │ 🐛 
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake.initiateSSL (package:mysql_client/src/mysql_client/connection.dart:294:16)
flutter: │ #1   MySQLConnection._processInitialHandshake.initiateSSL (package:mysql_client/src/mysql_client/connection.dart:293:31)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Initiating SSL connection
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake.initiateSSL (package:mysql_client/src/mysql_client/connection.dart:316:16)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 SSL connection established
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:337:12)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Auth plugin name is: caching_sha2_password
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processInitialHandshake (package:mysql_client/src/mysql_client/connection.dart:381:16)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Caching sha2 password response send
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection._processInitialHandshake.initiateSSL.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:323:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.initialHandshakeResponseSend
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:212:16)
flutter: │ #1   MySQLConnection._processInitialHandshake.initiateSSL.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:323:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ ⛔ Skipping invalid packet: [2, 0, 0, 3, 1, 3]
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection._processInitialHandshake.initiateSSL.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:323:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.initialHandshakeResponseSend
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:224:16)
flutter: │ #1   MySQLConnection._processInitialHandshake.initiateSSL.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:323:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 💡 Got OK packet. Connection established
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:163:12)
flutter: │ #1   MySQLConnection._processInitialHandshake.initiateSSL.<anonymous closure> (package:mysql_client/src/mysql_client/connection.dart:323:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing socket data. Current state is _MySQLConnectionState.waitingCommandResponse
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   MySQLConnection._processCommandResponse (package:mysql_client/src/mysql_client/connection.dart:391:12)
flutter: │ #1   MySQLConnection._processSocketData (package:mysql_client/src/mysql_client/connection.dart:233:7)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Processing command response packet
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: sql.connect

We could discuss the invalid packet related issue further the a new issue that seems to be dedicated to it, and stick to discussing how the workaround can be avoided on this thread/issue.

MHShetty commented 2 years ago

I connect my phone to laptop by USB cable. Setup port forwarding in Chrome devices tab. My system is linux. MySQL servers are inside docker containers.

I'm currently on a Windows machine running the regular MySQL 8 server and working directly with them (without Docker etc.).

zim32 commented 2 years ago

I will install MySQL 8, and test it

zim32 commented 2 years ago

Oh yeah. In mysql 8 I can see this packet ) This is good. Now I can work it out

zim32 commented 2 years ago

Ok I think this is something with caching_sha2_password authentication. As a temporary fix you can create user with native_password authentication, till I fix this issue.

CREATE USER 'test_native'@'%' IDENTIFIED WITH mysql_native_password BY '12345';

Then grant access for this user to your database and use it

MHShetty commented 2 years ago

Oh that's great, glad that the root cause of this issue was figured out )

Thanks a lot for looking into this issue @zim32!

zim32 commented 2 years ago

Ok. It should be fixed in latest release 0.0.23

MHShetty commented 2 years ago

Hi @zim32,

I'll try testing whether this issue is fixed by restarting my computer and checking if manually running the mysql command is any longer required. Will get asap.

zim32 commented 2 years ago

This issue was because, mysql server respond with different data depending on whether user was previously logged in or not. That is why I was not able to reproduce it and why it happens after restarting

Documentation also is very bad. It almost like reverse engineering the protocol

MHShetty commented 2 years ago

Hi @zim32,

Just tested the app after restarting the system and the library works as expected now.

Thanks a lot for looking into this issue in detail and fixing this! Keep up the good work @zim32 👍