Skip to content
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

Unhandled Exception: SocketException: Socket has been closed #33

Open
ThitSarNyanLynn opened this issue May 8, 2019 · 7 comments
Open

Comments

@ThitSarNyanLynn
Copy link

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):
E/flutter ( 4153): #1 MySqlConnectionImpl.connect (package:sqljocky5/connection/impl.dart:102:27)
E/flutter ( 4153):
E/flutter ( 4153): #2 MySqlConnection.connect (package:sqljocky5/connection/connection.dart:36:27)
E/flutter ( 4153): #3 main (package:f_sqljocky_test/main.dart:28:36)
E/flutter ( 4153):
E/flutter ( 4153): #4 _runMainZoned.. (dart:ui/hooks.dart:189:25)
E/flutter ( 4153): #5 _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 4153): #6 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 4153): #7 _runZoned (dart:async/zone.dart:1516:10)
E/flutter ( 4153): #8 runZoned (dart:async/zone.dart:1500:12)
E/flutter ( 4153): #9 _runMainZoned. (dart:ui/hooks.dart:180:5)
E/flutter ( 4153): #10 _startIsolate. (dart:isolate/runtime/libisolate_patch.dart:300:19)
E/flutter ( 4153): #11 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
E/flutter ( 4153):
Syncing files to device Android SDK built for x86...

@tejainece
Copy link
Contributor

Thanks for reporting. I will try to reproduce it.

Are you trying to connect to mysql server on desktop from Flutter?

@YuanTianyang
Copy link

I had the same problem

@jinfei
Copy link

jinfei commented Jan 28, 2020

I had the same problem,too

@ctcx
Copy link

ctcx commented Sep 7, 2020

@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)

@yusufnadar
Copy link

Is there any solution?

@4stern
Copy link

4stern commented Jun 8, 2021

this repo is down ..

@mastgaurav001
Copy link

I also had the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants