sqljocky5
sqljocky5 copied to clipboard
Unhandled Exception: SocketException: Socket has been closed
When I run this simple codes, I found the following error log.
import 'dart:async';
import 'package:sqljocky5/sqljocky.dart';
Future<void> createTables(MySqlConnection conn) async {
print("Creating tables ...");
await conn.execute('CREATE TABLE people (id INTEGER NOT NULL auto_increment, '
'name VARCHAR(255), '
'age INTEGER, '
'PRIMARY KEY (id))');
await conn.execute('CREATE TABLE pets (id INTEGER NOT NULL auto_increment, '
'name VARCHAR(255), '
'species TEXT, '
'owner_id INTEGER, '
'PRIMARY KEY (id),'
'FOREIGN KEY (owner_id) REFERENCES people (id))');
print("Created table!");
}
main() async {
var s = ConnectionSettings(
user: "root",
password: "",
host: "192.168.1.3",
port: 3306,
db: "ppms",
);
// create a connection
print("Opening connection ...");
var conn = await MySqlConnection.connect(s);
print("Opened connection!");
await createTables(conn);
await conn.close();
}
E/flutter ( 4153): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: SocketException: Socket has been closed
E/flutter ( 4153): #0 Comm.connect (package:sqljocky5/comm/comm.dart:182:5)
E/flutter ( 4153):
Thanks for reporting. I will try to reproduce it.
Are you trying to connect to mysql server on desktop from Flutter?
I had the same problem
I had the same problem,too
@tejainece when your password is error,you can catch this exception.
` file sqljocky5-2.2.1/lib/comm/buffered_socket.dart line 92: replace to onDataReady() } else if (event == RawSocketEvent.readClosed) { if (this.onClosed != null) { onDataReady(); //this.onClosed(); } }
` Run again after modification! I can catch this exception: Error 1045 (28000): Access denied for user 'user'@'ip' (using password: YES)
Is there any solution?
this repo is down ..
I also had the same problem.