jbenet / ios-ntp Goto Github PK
View Code? Open in Web Editor NEWSNTP implementation for iOS
Home Page: http://code.google.com/p/ios-ntp/
License: MIT License
SNTP implementation for iOS
Home Page: http://code.google.com/p/ios-ntp/
License: MIT License
There is a problem with the time obtained after modifying the system time. How can I use the correct network time
Sorry, guys .. I seem to lost the ability to make changes to this repository; no idea why. There are changes in half a dozen files that I cannot commit. I've been fighting this too long and am going to give up till my temper cools down and a pile of more important tasks as finished.
hey all, is it possible to achieve granularity down to the millisecond?
I experienced a crash when returning from background after a network connection loss.
Steps to reproduce:
Thanks.
I've added recent changes to the GCDAsyncUdpSocket code to my local repo, and that will be the basis for a v1.1.7 release as soon as v1.1.6 has settled down. I believe there will not be any functional changes to ios-ntp as a result.
It seems filter
may be reserved now?
#pragma mark I n b o u n d • D a t a F i l t e r
GCDAsyncUdpSocketReceiveFilterBlock filter = ^BOOL (NSData *data, NSData *address, id *context) {
return TRUE;
};
when application goes to background and i changed the device time in settings . then after that if i again make application active by tapping on it , then it's giving wrong gmt time . if i quit the application and launch it again , in that case it's working as expected . please suggest how to fix this
When i change the device time into the future,
the networkDate doing nothing.
Hi, I found the pollIntervals
is not in use. pollingIntervalIndex
can only be assigned 0/4/5/6. Is this correct?
Is this library suppose to work for xcode 6? I'm getting the following error when I tried using it following the instructions in the README:
ld: warning: ignoring file /Users/*******/Desktop/Dev/Blackout/Blackout/ios-ntp.framework/ios-ntp, missing required architecture arm64 in file Users/*******/Desktop/Dev/Blackout/Blackout/ios-ntp.framework/ios-ntp (2 slices)
Undefined symbols for architecture arm64:
"OBJC_CLASS$_NetworkClock", referenced from:
objc-class-ref in BOAppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Not to mention that I needed to #import using #import <ios-ntp/ios-ntp.h> not "ios-ntp.h"
iOS-ntp returning same value as device, when i change device time network time change as well please help what m i missing? as i check didReceiveData not get called in NetAssociation.
I'm trying to do one-off queries of the NTP server using sendTimeQuery
. I thus never enable my NetAssociation but it gets enable by the foregrounding event. I just commented those sections out for my own use, but you might want to do some kind of check of whether the user wants the services enabled at all.
Hi
First, thank you because you provide such code for all coders!
Thank you again.
But i has some issue as follow:
Best regards.
This causes -finish and -enable to be called additional times for the same instance. Reproducible by locking/unlocking the phone. After unlocking for the 5th time, the UI starts to lag while -enable is being called, and ultimately leads to a crash in GCDAsyncUDPSocket.
hi again. What about finishing/clearing the timeAssociations
array in NetworkClock.m, whenever createAssociationsWithServers:
is called? (Assuming it were filled).
Given how infrequently a lot of users update their apps.... I think it would be handy to be able to remotely fully refresh the time servers. (Right now would have to wait until the app was rebooted).
一直是本地时间 即使本地时间修改后也会跟着本地时间变
Hi there! Great project and thanks for the time you've spent on it over the years.
Have you considered adding a CocoaPod spec to the repo so people can very easily integrate it into their Xcode projects?
Integration would then be as simple as me adding pod 'ios-ntp'
and then running pod install
and it'd add it to Xcode and automatically pull in a stable/tested version of CocoaAsyncSocket
pod from their repo as well so you wouldn't have to maintain that code in your own repo. This allows teams of people to all effortlessly have the same code and setup.
All you'd need to do is:
.podspec
file (I created a template for you in the commit below)git tag -a v1.0.0 -m "v1.0.0"
, reference that version in the podspec file, and push it up for us.trunk
tool if you'd like the spec in their central repo so others can easily find it by searching for NTP
: http://guides.cocoapods.org/making/getting-setup-with-trunk.htmlI've tweaked your project slightly to work with CocoaPods and added a podspec to our own repo for now (luxe-eng@f1fee66) since we need the library today, but we would really appreciate you considering this.
Thanks!
In udpSocket: didReceiveData: fromAddress: withFilterContext:
you grab the ntpClientRecvTime, then you call decodePacket:
and grab it again right after?
I assume the 2nd one should be skipped, plus it'll be about 8 nanoseconds later.
I'm using NetAssociation
for one-time check, and I found sometimes it won't work.
I have check your code, and found you are using UDP socket, I'm not sure but if my problem is due to the UDP protocol? I want to know do you have some work to make sure the one-time check always work well even using UDP.
是从苹果服务器上获取的时间吗?
Right now if you use NetAssociation
in one-off mode, and the UDP packet gets lost and never arrives... the delegate method would never be called.
Maybe there should be some timeout, and success/failure reporting?
Block-based would also be heavenly :)
I see this error on NetAssociation.m:
...Pods/ios-ntp/ios-ntp-lib/NetAssociation.m:116:17: Method override for the designated initializer of the superclass '-init' not found
on Xcode 7.2, iOS 9.2.
Hello. Do you have ntp server for ios demo??
i want to run the ntp server on iphone.
help me! please
Version 1.1.3 is not taking suspect NetAssociations out of the pool.
Doesn't happen often, but occasionally sendTimeQuery
locks up the main thread in the beginReceiving
for as much as 10-15 seconds:
- (void) sendTimeQuery {
NSError * error = nil;
[socket sendData:[self createPacket] toHost:server port:123 withTimeout:2.0 tag:0];
if(![socket beginReceiving:&error]) {
NTP_Logging(@"Unable to start listening on socket for [%@] due to error [%@]", server, error);
return;
}
}
Breaking on this, it seems it's getting stuck in GCSAsyncUdpSocket's on dispatch_sync(socketQueue, block);
Any insight into what could be going wrong? Ideally, none of this should ever be touching the main thread.
I'm new to creating frameworks, so maybe this is not a big issue. I cannot seem to create the iosntp.tar.gz file in the release folder that I suspect contains the framework files. how is this done?
When I change my clock forward n minute, the time I receive is forward 2*n minute. The networkTime is double wrong
Ex: If current server time is 15:30. I change my phone time to 15:33. The networkTime I receive from [NetworkClock sharedNetworkClock].networkTime
is 15:36
I use it by call [NetworkClock sharedNetworkClock]; in application:didFinishLaunchingWithOptions: and get [NetworkClock sharedNetworkClock].networkTime
in a button touch event.
It happen from version:
c6f2d2b
Restructure so the NetAssociations tick and hold state as independent…
In correct version, I see networkTime adding has "-" sign:
return [[NSDate date] dateByAddingTimeInterval:-timeIntervalSinceDeviceTime/1000.0];
But current version is missed
return [[NSDate date] dateByAddingTimeInterval:[self networkOffset]];
Hi, I'm having issues when I call networkOffset method, I get a bad_access error.
@interface NTPClient:NSObject{
NetworkClock * nc;
}
- (id)init;
- (bool)isInitialized;
- (Array<int>)now;
@end
@implementation NTPClient
- (id)init {
self = [super init];
nc = [NetworkClock sharedNetworkClock];
// NSDate * nt= nc.networkTime; <-----It's fine if I call it here
return self;
}
- (bool) isInitialized{
return true;
}
- (Array<int>) now {
// nc = [NetworkClock sharedNetworkClock];
NSDate * nt= nc.networkTime; // <-------------- It breaks here
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:nt];
Array<int> a= *new Array<int>;
a[0] = (int)[components year];
a[1] = (int)[components month];
a[2] = (int)[components day];
a[3] = (int)[components hour];
a[4] = (int)[components minute];
a[5] = (int)[components second];
a[6] = 0;
return a;
}
@end
Thanks
I'm watching an issue in the https://github.com/robbiehanson/CocoaAsyncSocket that ios-ntp
uses, there is an open report of the UDP echo client/server sample perhaps not receiving packets back. Two people have reported the issue, one in May, the other today. Nothing to be done yet .. but I'll keep an eye on it.
This was working fine for some time, but then something changed. I traced the calls and every call of [NetAssociation evaluatePacket] the good = 0, fail = 1, unused = 7. And it skips the assoc-fail/good notification part.
I was wondering what could affect it? Could there be a flag in the Build Settings? The code is part of a library, which hasn't been changed. But it stopped working. By the way, I tried different NTP servers and nothing helps.
I would really appreciate the help.
I'm trying to stop the user from setting their clock forward to gain access to content ahead of time. But, when I manually set my device time, ios-ntp returns the false time. It looks like the offset from the timeservers is too great, so they're all marked as untrustworthy?
Hi!
I'm in Brasil and to reduce the connection lag with ntp servers would be great if I could use my own ntp.hosts
files.
There is a recommended way to accomplish that? (I'm using CocoaPods btw)
Great job! Thanks ;)
Your project is very good but I have one question: does your project compensate for the time it takes to receive the answer from the time server? I mean, I request the time, the server answers at t = 0
, but there is a delay between the time the server answers and the time I receive it. Does your project corrects for that delay? thanks!
ios-ntp
is not performing correctly with the iOS 9.3 public beta.
When I put the app in background, change the time from settings and then go back to the application, it seems that it is returning the wrong network time. Do you have any work around for this? Thank you very much in advance.
Please don't hard code NTP Pool (pool.ntp.org) hostnames. It appears one of your users had a bad implementation and caused considerable havoc on the system. Leave the list empty and reference http://www.pool.ntp.org/vendors.html
Hi,
I found that released version on Cocoa pods (1.1.1) is different comparing to this repository (1.1.3).
Could you check and fix this?
Thanks!
I'm using ios-ntp via CocoaPods, but the only version I can get is 1.0.1. I'd really like to get the fix for the re-entrancy bug without having to switch away from the CocoaPods version. Could someone please push 1.1 out to the CocoaPods repository?
In the README it is mentioned
This project contains code to provide time obtained from standard time servers using the simple network time protocol (SNTP: RFC 5905). The implementation is not a rigorous as described in that document since the goal was to improve time accuracy to tens of milliSeconds, not to microseconds.
I was wondering if more detail could be given about what portions of the 5905 spec are not implemented. Specifically, is it possible to extend this implementation to provide even more accurate time than iOS now has out of the box?
When [NetworkClock sharedNetworkClock] is first called when there is no internet connection, no network associations will be created, meaning that no timers are ever created, so even when internet is back on at a later point in time, nothing will happen / no pings to any time servers will happen.
Hi,
I will be using your library on one of my iOS projects soon but have a been a bit worried because after running ios-ntp through AppCode's static analysis there are a lot of valid warnings. For example in various places an integer is return from a function that is supposed to return an unsigned integer. -- see GCDAsyncUdpSocket.m line 1663. Though it doesn't speak to whether the library works or not it would be great if you could fix the code up a bit in the hopes of maybe prevent any crashes or problems that may occur. See Appcode at https://www.jetbrains.com/objc/
Thanks
This is not really an issue, but I'm not sure the proper way to go about asking...
Rather than continuously running, I would like to stop ios-ntp as soon as it reaches a "reasonably accurate" offset from the system clock.
I saw the following comments:
"It will take about one minute before untrustworthy servers start to get
dropped from the pool.
It would probably be better if NetworkClock called back to a delegate
method, like NetAssociation does below, when it had a good time but
that's not how it works, yet, so you have to wait till things settle
down."
So how can I determine when it has a "good time", or should I wait 10 seconds or so, or wait a full minute?
Thanks!
When i was use this library in cocoa pods i found two error . First is the version 1.1.4 is not on the pod repo. Second is when i enable use_frameworks in pod file there will be occur an import error about
#import "GCDAsyncUdpSocket.h"
if i replace to @import CocoaAsyncSocket;
will fix this error.
Hope you fix these errors. Thanks.
when not network to network, error: " dnssd_clientstub deliver_request ERROR:"
Trying to compile target ios-ntp -> iPhone 6.1 simulator
Getting:
lipo: can't open input file: /Users/me/Library/Developer/Xcode/DerivedData/ios-ntp-dugtdxdmajqvrpbzrxshalcsxzng/Build/Products/Debug-iphoneos/ios-ntp.framework/ios-ntp (No such file or directory)
When the source files of ios-ntp are added to a project, trying to compile gives an error from NetAssociation.h because of importing a non-existent <CocoaAsyncSocket/GCDAsyncUpdScoket.h>
From what I can gather, this is not a Cocoa system library, but apparently some random third-party library from somewhere. This doesn't seem to be included in the ios-ntp git project, nor can I find a single mention of it anywhere in its documentation, apart from an obscure "the files from CocoaAsyncSocket have been replaced with the most recent versions" (which quite clearly is untrue, as no such files are found anywhere in the ios-ntp git project.)
Like many others I use NTP to detect time manipulation, and to retrieve accurate time. This is often difficult to deal with when a user leaves the app, changes the time, comes back, and NTP takes a bit of time to figure out the new offset.
Would it be possible to get an NTP response with an offset, and associate it with the current systemUptime
? Once established, seconds since uptime would becoming a meaningful measure of time and we wouldn't need further NTP checks or to use the system time.
Does this seem plausible?
cc @gavineadie
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.