shaqian / flutter_ssh

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

Error instantiating client #21

Closed ralph-fuechtenkort closed 4 years ago

ralph-fuechtenkort commented 4 years ago

Good Morning, just try to integrate flutter_ssh. pubspec and import works fine but actually trying to connect i always receive the error "unknown_client". I am using it on a machine with android 7.1 and i also have included the libraries dependency in the build grade file.

Any help solving my "stupid" error" highly appreciated :)

Greets from Manila

Ralph

ralph-fuechtenkort commented 4 years ago

Sorry just to be sure here the code: var _sshClient = SSHClient(host: _currentTerminal.fiscalStorageUrl,port:_currentTerminal.fiscalStoragePort,username:_currentTerminal.fiscalStorageUser,passwordOrKey: _currentTerminal.fiscalStoragePassword,); try{ print('Start sftp connect'); String _result = await _sshClient.connectSFTP(); if (_result == "session_connected"){ await _sshClient.sftpUpload(path:localDir.toString() + "/*.txt",toPath: "/var/local/fiscalStorage", callback: (progress) { print(progress); // read upload progress }, ); await _sshClient.disconnectSFTP(); await localDir.delete(); } } on PlatformException catch (e){ print('Error: ${e.code}\nError Message: ${e.message}'); }

shaqian commented 4 years ago

Hi @ralph-fuechtenkort

You need client.connect() before client.connectSFTP(). Refer to the example code here: https://github.com/shaqian/flutter_ssh/blob/master/example/lib/main.dart#L117-L119

      String result = await client.connect();
      if (result == "session_connected") {
        result = await client.connectSFTP();

Thanks, Qian