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

getNtpOffset fails on web with “Unsupported operation: InternetAddress.lookup” #15

Closed
amatveiakin opened this issue May 8, 2020 · 23 comments
Assignees
Labels
bug Something isn't working

Comments

@amatveiakin
Copy link

Does ntp package support web? Web isn't explicitly mentioned in the list of supported platforms at https://pub.dev/packages/ntp, but I was under impression that the package is written in native dart and should work on all platforms.

However when I try to call getNtpOffset from a web app, it fails with “Unsupported operation: InternetAddress.lookup”.

Tested in Firefox and Chrome, in a debug build running on local host and in a release build deployed to Firebase hosting. Using Dart 2.8.1, Flutter 1.17.0-3.4.pre, ntp 1.0.6.

@knezzz knezzz self-assigned this May 10, 2020
@knezzz knezzz added the bug Something isn't working label May 10, 2020
@knezzz knezzz closed this as completed in 0f0d1a4 May 10, 2020
@knezzz knezzz reopened this May 10, 2020
@knezzz
Copy link
Owner

knezzz commented May 10, 2020

Thanks for reporting the issue :D

Looks like I'll have to find better solution for this.
This is because dart:io is not supported on web.

@amatveiakin
Copy link
Author

Thanks! I'm a bit confused about the status of this issue now :) Was 0f0d1a4 supposed to work around dart:io problem?

I've updated to the new version and now getNtpOffset throws an UnimplementedError.

@knezzz
Copy link
Owner

knezzz commented May 11, 2020

It was supposed to fix it yeah. There was package I found universal_io that is supposed to work on web, but it was not working when I tested it so I reopened the issue :/ (github automatically closes the issue if issue number is in commit message)

@expilu
Copy link

expilu commented Jul 13, 2020

Interested in support for web too :)

@knezzz
Copy link
Owner

knezzz commented Jul 15, 2020

Okay, will look up how can I make it work on web as well :)

@itschrono
Copy link

Hello. How is it going? Do you need a hand?

@knezzz
Copy link
Owner

knezzz commented Sep 17, 2020

Hey @itschrono. Sure if you have time I can assign it to you.
I didn't have much luck with universal_io.

@itschrono
Copy link

itschrono commented Sep 17, 2020 via email

@nelsonjohn045
Copy link

Hi. when can we expect an update on this?

@itschrono
Copy link

itschrono commented Sep 22, 2020 via email

@nelsonjohn045
Copy link

Thanks I appreciate it. meanwhile I'll try to come up with something, if I do I'll ping here.

@itschrono
Copy link

Hello,

dgram and raw socket are a no go in web browser. The only options are: http(s) 1.1 or websocket. This means it is not going to work with this ntp protocol. The api can still be the same if the lookUpAddress support both connection types.

@a-elhaddad
Copy link

Any news about fix?

@itschrono
Copy link

itschrono commented Oct 1, 2020 via email

@knezzz
Copy link
Owner

knezzz commented Oct 3, 2020

@itschrono How did you get host address (The InternetAddress.lookup part that is failing here)? Can something like that be implemented here?
I was looking today a bit at other solutions but coundn't find anything that works 😞

@itschrono
Copy link

itschrono commented Oct 3, 2020 via email

@oonid
Copy link
Contributor

oonid commented Jan 12, 2021

hi @knezzz
do you think it is possible to construct the InternetAddress if we have the IP Address?
if so, I think one idea is to build DNS utility with the implementation of DNS-over-HTTPS (DoH).
https://developers.google.com/speed/public-dns/docs/doh

this is one example:
https://github.com/Ephenodrom/Dart-Basic-Utils/blob/master/lib/src/DnsUtils.dart

thoughts?

@knezzz
Copy link
Owner

knezzz commented Jan 18, 2021

Hi @oonid, sorry for not getting back sooner, I wanted to reply when I test this but I still didn't have a chance to try it.

Looks promising, and that will solve the web issue for sure so I will definitely try it.

Thanks for suggestion 😄

@oonid
Copy link
Contributor

oonid commented Jan 18, 2021

hi @knezzz
I have added PR #27
would you please review and edit it for better implementation?

@knezzz knezzz closed this as completed in 16c49d6 Jan 19, 2021
@ma-ruz
Copy link

ma-ruz commented Mar 10, 2021

Hello,
with 1.0.8 I'm getting this error on web:

Error: UnimplementedError
at Object.throw_ [as throw] (http://localhost:55438/dart_sdk.js:5348:11)
at bind (http://localhost:55438/packages/universal_io/src/io_impl_js/sync_socket.dart.lib.js:3434:21)
at bind.next ()
at runBody (http://localhost:55438/dart_sdk.js:39211:34)
at Object._async [as async] (http://localhost:55438/dart_sdk.js:39242:7)
at Function.bind (http://localhost:55438/packages/universal_io/src/io_impl_js/sync_socket.dart.lib.js:3431:20)
at getNtpOffset (http://localhost:55438/packages/ntp/ntp.dart.lib.js:128:63)
at getNtpOffset.next ()
at http://localhost:55438/dart_sdk.js:39191:33
at _RootZone.runUnary (http://localhost:55438/dart_sdk.js:39048:58)
at _FutureListener.thenAwait.handleValue (http://localhost:55438/dart_sdk.js:34034:29)
at handleValueCallback (http://localhost:55438/dart_sdk.js:34594:49)
at Function._propagateToListeners (http://localhost:55438/dart_sdk.js:34632:17)
at _Future.new.[_completeWithValue] (http://localhost:55438/dart_sdk.js:34474:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:55438/dart_sdk.js:34497:35)
at Object._microtaskLoop (http://localhost:55438/dart_sdk.js:39335:13)
at _startMicrotaskLoop (http://localhost:55438/dart_sdk.js:39341:13)
at http://localhost:55438/dart_sdk.js:34848:9

I'm quite new to flutter web but it looks like the update didn't solve the problem...

@capce
Copy link

capce commented Mar 15, 2021

I have the exactly same error as @ma-ruz posted.

[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.19041.804], locale de-DE)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.54.1)
[√] Connected device (2 available)

opened a new issue #32

@Toolenaar
Copy link

It seems this error still exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests