shaqian / flutter_ssh

SSH and SFTP client for Flutter
https://pub.dartlang.org/packages/ssh
MIT License
117 stars 83 forks source link

SFTP closing with InputStream closed exception #53

Open boganiLuca opened 3 years ago

boganiLuca commented 3 years ago

Hello,

I'm trying to connect to a device from my own Flutter app, but when I try to connect to SFTP I get the following error:

I/flutter ( 6530): timer triggered I/art ( 6530): Background sticky concurrent mark sweep GC freed 11068(504KB) AllocSpace objects, 14(372KB) LOS objects, 21% free, 4MB/5MB, paused 5.367ms total 14.984ms I/flutter ( 6530): ssh connected E/SshPlugin( 6530): Error connecting SFTP:java.io.IOException: inputstream is closed I/flutter ( 6530): Error: sftp_failure I/flutter ( 6530): Error Message: java.io.IOException: inputstream is closed

This is my code:

  Timer(const Duration(seconds: 30), () async {
  print("timer triggered");

  if (_sshClient == null) {
    _sshClient = new SSHClient(
      host: _strumAddress,
      port: 22,
      username: "****",
      passwordOrKey: "******",
    );
  }
  try {
    String result = await _sshClient.connect();
    if (result == "session_connected") {
      print("ssh connected");
      var result;
      result = await _sshClient.connectSFTP();
    }

  } on PlatformException catch (e) {
    print('Error: ${e.code}\nError Message: ${e.message}');

    _sshClient.disconnect();
    _sshClient = null;
  }
});

I only tested on Android, and I'm sure that the server is running, and that credentials are correct (I can connect from Windows using pscp.exe and OpenSSH 'spc' command). Is there any hint you can give me? Some way to have a verbose output that may share some light on this? Thanks in advance