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

Socket Support on Web broken #45

Open
RiRa12621 opened this issue Oct 13, 2022 · 7 comments
Open

Socket Support on Web broken #45

RiRa12621 opened this issue Oct 13, 2022 · 7 comments

Comments

@RiRa12621
Copy link

RiRa12621 commented Oct 13, 2022

I am fairly new to flutter and trying to implement a simple ssh-client in a terminal view. However when I test it on web, I get errors along the lines of

Error: UnimplementedError: Native socket is not supported on web

So, I am not handling the error, but the actual error could maybe be fixed following the comments in the bug report to flutter/flutter: flutter/flutter#45982 (comment) which should, to my understanding, be implemented in the following line:

final socket = await Socket.connect(host, port, timeout: timeout);

my code for the ssh connections looks as follows:

    final client = SSHClient(
      await SSHSocket.connect(host, port),
      username: username,
      onPasswordRequest: () => password,
    );
@payamss
Copy link

payamss commented Jan 23, 2023

same here Error: UnimplementedError: Native socket is not supported on web

@mewforest
Copy link

Same here, problem it still exists on web 👎🏻

Does anyone know, is the problem exists on earlier versions?

  final socket = await SSHSocket.connect('localhost', 22);

  final client = SSHClient(
    socket,
    username: 'root',
    onPasswordRequest: () => '1234567',
  );

Error:

Uncaught (in promise) Error: UnimplementedError: Native socket is not supported on web
    at Object.throw_ [as throw] (errors.dart:263:21)
    at connectNativeSocket (ssh_socket_js.dart:8:3)
    at connectNativeSocket.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:123:5)
    at Object.connectNativeSocket (ssh_socket_js.dart:3:38)
    at connect (ssh_socket.dart:13:18)
    at connect.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:123:5)
    at SSHSocket.connect (ssh_socket.dart:8:35)
    at connect (main.dart:12:34)
    at connect.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:123:5)
    at Object.connect (main.dart:11:13)
    at main$ (main.dart:8:3)
    at main.dart.bootstrap.js:303:10
    at Array.forEach (<anonymous>)
    at window.$dartRunMain (main.dart.bootstrap.js:302:32)
    at <anonymous>:1:8
    at Object.runMain (client.js:8803:21)
    at client.js:24896:19
    at _wrapJsFunctionForAsync_closure.$protected (client.js:3448:15)
    at _wrapJsFunctionForAsync_closure.call$2 (client.js:11507:12)
    at Object._asyncStartSync (client.js:3412:20)
    at main__closure4.$call$body$main__closure (client.js:24912:16)
    at main__closure4.call$1 (client.js:24824:19)
    at StaticClosure._rootRunUnary (client.js:3816:16)
    at _CustomZone.runUnary$2$2 (client.js:12906:39)
    at _CustomZone.runUnaryGuarded$1$2 (client.js:12853:14)
    at _ControllerSubscription._sendData$1 (client.js:12446:19)
    at _DelayedData.perform$1 (client.js:12629:59)
    at _PendingEvents_schedule_closure.call$0 (client.js:12688:14)
    at Object._microtaskLoop (client.js:3656:24)
    at StaticClosure._startMicrotaskLoop (client.js:3662:11)
    at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (client.js:11384:9)
    at invokeClosure (client.js:1227:26)
    at MutationObserver.<anonymous> (client.js:1246:18)

@ganeshchenniah
Copy link

Hi ,

Is there any update on this issue ? i m also looking for the solution

@khaipg
Copy link

khaipg commented Mar 20, 2023

Same
Error: UnimplementedError: Native socket is not supported on web

@rickmeulendijks
Copy link

Same here.
Like to use this for web.

@xtyxtyx
Copy link
Member

xtyxtyx commented Apr 4, 2023

Hello,

Sorry for the delay in my response. It's actually intended that SSHSocket don't provide a default implementation on web platform as there is no standard method for connecting to sockets in browsers. Instead you can implement the SSHSocket interface use whatever available in the browser such as bare WebSocket, socket.io, WebRTC data channels or WebExtension native messaging.

Please let me know if you have any further questions or concerns.

@RiRa12621
Copy link
Author

Fine to close, if it's intended behaviour

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

7 participants