dartssh2 icon indicating copy to clipboard operation
dartssh2 copied to clipboard

Error when reading '/[C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/dartssh2-2.4.4/lib/next/socket/ssh_socket_js.dart]()': 系统找不到指定的路径。

Open 13692277450 opened this issue 2 years ago • 6 comments

Hi Owner,

I try to use your ssh2 and found below error,would you pls double check and reply?

Many Thanks. Zhangmang [email protected]

Launching lib\main.dart on Chrome in debug mode... lib\main.dart:1 /C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/dartssh2-2.4.4/lib/src/socket/ssh_socket.dart:4:8: Error: Error when reading '/C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/dartssh2-2.4.4/lib/next/socket/ssh_socket_js.dart': 系统找不到指定的路径。

import 'package:dartssh2/src/socket/ssh_socket_io.dart' package:dartssh2/…/socket/ssh_socket_io.dart:1 ^

/C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/dartssh2-2.4.4/lib/src/socket/ssh_socket.dart:13:18: Error: Method not found: 'connectNativeSocket'. return await connectNativeSocket(host, port, timeout: timeout); ^^^^^^^^^^^^^^^^^^^

13692277450 avatar Feb 03 '22 12:02 13692277450

Hello, It looks like you're using dartssh2 in browser. Currently no browser supports opening TCP connections and to use dartssh2 you have to either compile your app to desktop/mobile version, or implement your own SSHSocket that relies on other underlying transports such as WebSocket or SSE.

xtyxtyx avatar Feb 03 '22 12:02 xtyxtyx

By the way I'd like to hear what you want to build with dartssh2 so I can tailor the package to better fit your (and other's) needs.

xtyxtyx avatar Feb 03 '22 12:02 xtyxtyx

Two important things:

  1. Regarding a fix for the error IN ADDITION TO the implementation of our own SSHSocket while waiting for you to get it working, in ssh_socket.dart, line 5 should read if (dart.library.js) 'package:dartssh2/src/socket/ssh_socket_js.dart';, not if (dart.library.js) 'package:dartssh2/next/socket/ssh_socket_js.dart';. The problem lies in the fact that there is no next directory.

By the way I'd like to hear what you want to build with dartssh2 so I can tailor the package to better fit your (and other's) needs.

  1. I am using dartssh2 to connect to a proxy server, which then connects to other devices from there. Using XTerm to customize and handle the terminal display on the web. Which means, it would be nice to have a friendly way to print responses back for my terminal, while filtering only the needed responses...for some things need to be handled autonomously.

warrenm1 avatar Feb 08 '22 18:02 warrenm1

Thanks for reporting! @warrenm1 The import path issue has been fixed in 2.5.0.

while filtering only the needed responses

Could you provide an example about this?

xtyxtyx avatar Feb 09 '22 15:02 xtyxtyx

@xtyxtyx when using the dartssh, we implemented the SSHClient thusly

SSHClient( hostport: Uri.parse(_host), login: _username, print: print, termWidth: 80, termHeight: 25, termvar: 'xterm-256color', getPassword: () => utf8.encodeBytes(_password), response: (transport, data) { if (!_baseConnected) { if (data.contains('Are you sure you want to continue connecting')) { _client.sendChannelData(utf8.encodeBytes('yes\n')); } if (data.contains('root@localhost's password:')) { _client.sendChannelData(utf8.encodeBytes('$_password\n')); setState(() { _delayIndex = 0; // additional local logic }); } } else { _terminal.write(data); } }, success: () async { _proxyConnected = true; _terminal.write('proxy connected.\n\r'); // additional logic to connect to devices }, disconnected: () { _terminal.write('disconnected.\n\r'); if (mounted) { setState(() { // local variable logic }); } }, debugPrint: (str) { // logging logic }, tracePrint: (str) { // logging logic });

Particularly the logic found within the response value.

warrenm1 avatar Feb 09 '22 23:02 warrenm1

@xtyxtyx just to clarify, needing to verify that my ssh connection within the proxy (that I used the SSHClient to connect to) actually occurred, otherwise I will be in an endless loop of connecting->exposing device to a different port...which closes the ssh session->connecting to that new port-> exposing device to a different port...etc

We had some local logic to account for that loop, but get stuck in that loop without the response handled similarly to how it was in dartssh.

warrenm1 avatar Feb 15 '22 22:02 warrenm1