Coder Social home page Coder Social logo

artem-russkikh / react-native-ntp-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moonpyk/node-ntp-client

13.0 13.0 10.0 105 KB

React Native compatible implementation of the NTP Client Protocol (https://github.com/moonpyk/node-ntp-client fork)

License: MIT License

JavaScript 100.00%
ntp ntp-client ntp-library ntp-protocol ntpdate react-native udp

react-native-ntp-client's People

Contributors

artem-russkikh avatar info-bit avatar moonpyk avatar naggie avatar onebigdoor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-ntp-client's Issues

[ANDROID] Get "Invalid date" on real device

Hi,
I'm trying to use this library to get network time in a chat system to avoid to get device date since the user can manually set the date/time on his device.

I'm testing with this example code retrieved from documentation:

ntpClient.getNetworkTime("pool.ntp.org", 123, (error, date) => {
  if (error) {
    console.error(error);
    return;
  }
  console.log(date);
});

While on iOS simulator this works as expected (I haven't tried it on real iOS device yet), on real Android device I'm getting this error on console:

'socket-0', 'bound to address:', '0.0.0.0', 'port:', 0
'socket-0', 'closing'
Invalid Date
'socket-0', 'closed'

What can this error be due to? Notice that I set a manual date/time to test this snippet.

My packages.json:

...
"react": "16.8.6",
"react-native": "0.60.6",
"react-native-clock-sync": "1.1.0-a",
"react-native-ntp-client": "1.0.0",
"react-native-udp": "2.6.1",
...

TypeError: dgram.createSocket is not a function.

This is error is showing up with React Native 0.62.2 and react-native-udp 4.0.2.

TypeError: dgram.createSocket is not a function. (In 'dgram.createSocket("udp4")', 'dgram.createSocket' is undefined)

This is located at ntp-client.js:39:21

var client = dgram.createSocket("udp4"),
ntpData = new Buffer(48);

Will appreciate any help on this. This issue has become a blocker for us. Thanks.

No client found with id 18

Every few requests I'm getting the above error (it's not always 18, though, it can be several other numbers). I have tried with several different NTP servers and I'm still getting this error. Any idea what could be going wrong?

ERROR_SOCKET_BAD_PORT

screenshot-2020-09-18_09 22 59 103

anyone can help me please ?
i don't know what's the problem of my error

this is my code

componentDidMount() {
    ntpClient.getNetworkTime("time.google.com",881, (error, date) => {
        if (error) {
            console.error(error);
            return;
        }

        console.log(date); // Mon Jul 08 2013 21:31:31 GMT+0200 (Paris, Madrid (heure d’été))
    });
}

and in Log show this

error

Thank you in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.