Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Web NTP - Invalid ntp Response
Author | Message | ||||
Malibu Senior Member Joined: 07/07/2018 Location: AustraliaPosts: 228 |
Good morning all... It's been a long time between drinks on using any of the MM varieties, but I'm starting back and using the WebMite for a time based controller project. So, first things first in the code, I set the time and date using WEB NTP and all works well because it accesses an NTP server as it should, but ideally, I'd like to use my 'local' machine as an NTP Server which is where I get stuck. My server is a HP Proliant running Windows Server 2008 OS. On that I have the NtpServer 'enabled' according to the registry editor, plus Windows Time service is running. That should enable the HP to act as a local NTP Server (as far as I understand the way it works) and firewall is turned off for the local network. Here's the code I'm using (with my comments left in...): SUB SetTimeDate 'Get and set the time/date dim string Ntp1$="1.2.3.4", Ntp2$="192.168.0.2" 'Assign addresses ShowMessage "Pre-set time: " + time$ 'show the Initial time on error skip 1 'Watch out for an error WEB NTP 10, Ntp2$ 'Attempt to get the time/date and set the internal RTC if mm.errno then 'If there was a problem ShowMessage "An '" + MM.Errmsg$ + "' error occurred..." 'Display the problem exit sub 'Early exit end if ShowMessage "The date/time is set to: " + DATE$ + " " + TIME$ 'All good, show the set time ShowMessage DAY$(NOW) 'Show what day it is END SUB SUB ShowMessage msg$ 'generic routine to print messages PRINT msg$ END SUB Ntp1$ is a dud address so I can flag a fault, and Ntp2$ is my local server address (I did it with strings so I can easily change addresses) If I run code 'WEB NTP 10', I get a good time stamp from a default time server... If I run code 'WEB NTP 10, Ntp1$', I get an "NTP timeout" error... (expected) If I run code 'WEB NTP 10, Ntp2$', I get an "Invalid NTP Response" error... Playing with Windows Server OS settings, restarting the time service etc makes no difference to the result. If I stop the Windows OS time service, I also get a timeout error (as expected) I presume that the Windows server is sending data that the WebMite doesn't understand, but I'm not sure what the fix is, or what is being sent. Any clues that might point me in the right direction to fix it? John |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6100 |
Try using your router as the NTP server. They usually do it and will be more likely to comply with the standards. VK7JH MMedit MMBasic Help |
||||
Malibu Senior Member Joined: 07/07/2018 Location: AustraliaPosts: 228 |
Thanks for the hint... I tried that option previously, but it looks like my router doesn't have an option to become a NTP Server (not that I can find, anyway) After battling this one for a couple of days, I finally got it working. There's a couple of things I missed on the Windows Server... First, I set the 'AnnounceFlags' using RegEdit and, second, created Firewall Inbound/Outbound rules and set them to Ports=All. The windows NTP uses Port 123 and I thought maybe because the Webmite is using port 80, it might have a mix-up there. Whatever the final reason was, it's all working now,,, - and the reason I'm going down this path is that 99.9% of the time, the clock will be set using a public ntp server. The remaining 0.1% of time is a fall-back IF the internet is down, I can still set the time via the local network. Thanks again John |
||||
Print this page |