0

Can someone help me regarding the Local NTP server in Python. The python code is below:

import ntplib
from time import ctime
while True:
 try:
  c = ntplib.NTPClient()
  response = c.request(host='192.168...',port=2947)
  print(response)
  print(ctime(response.tx_time))
 except Exception as e:
    print(e)

When i run this code, the output returns no response received from 192.168....

  • Is a server running at `host='192.168...',port=2947` ? – Maurice Meyer Apr 02 '21 at 10:40
  • Yes , exactly , this is my local server – asher sajid Apr 02 '21 at 11:12
  • I think the remote ntp server ('pool.ntp.org') send the data through udp port but in my case the local server send the data through tcp port. Can you guide me how can i resolve this error – asher sajid Apr 02 '21 at 11:16
  • The port specified in request() is for a UDP not a TCP port to a NTP service. If you're listening on TCP socket then the server will never get the UDP datagram packet and the client won't get a response. – CodeMonkey May 31 '21 at 20:37

0 Answers0