Time wrong with OSMC @ RPI2

Just a couple of additional notes:

I have a webcam which uploads images to my web host about every two minutes. If there was an Internet connection problem, it would be noted in the log file. Nothing for the time period immediately before and after Oct 28 14:05:09.

I also keep a log of changes in external IP address. This is usually caused by a dropped ADSL connection. Here are the entries for the time period around October 24 at 1400:

Wed Oct 28 12:58:39 ICT 2015 49.48.99.42

Wed Oct 28 13:58:45 ICT 2015 223.207.172.195

Wed Oct 28 16:38:57 ICT 2015 49.48.85.175

Wed Oct 28 17:18:59 ICT 2015 49.48.92.196

@DBMandrake is Simon

1 Like

Iā€™ve posted the log covering October 28th through early today (November 3rd).

journalctrl

During that period there have been seven instances of:

Time has been changed

and one instance of:

No internet connectionā€¦

During the last 72 hours my Internet throughput and stability have been as good as they ever get.

Let me know if thereā€™s anything more I can do here.

I think from looking at your logs the large time jumps you are seeing can only be caused by bad ntp servers whose time is wrong by many hours. ā€œTime has been changedā€ is a systemd message that alerts you when the time has been changed by a large amount.

Even if ntpd just crashed by itself, the time would not suddenly be out by hours, it would still be correct but then very gradually drift, no more than a few seconds per day most likely.

Large jumps in time can only mean that it is syncing with bad servers. We really need to see the output of this command, taken at multiple times of the day, before and after the time is wrong:

ntpq -c peers

This command needs to be run when ntpd is running otherwise it wonā€™t give any useful output.

Also, can you please turn on debugging for ntp, by editing /etc/ntp.conf, remove the comment # from the statsdir line (second line below):

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

Then restart the ntp service. This will enable logging in /var/log/ntpstats. After the problem occurs, please post the logs:

paste-log /var/log/ntpstats/peerstats
paste-log /var/log/ntpstats/loopstats

OK, I will do my best to do all. I did the ntpq -c peers for four machines on my LAN:

Pi Running OSMC:

osmc@OSMCBR:~$ ntpq -c peers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*203.146.215.116 202.47.249.20    2 u  217  256  377   64.139    7.268  37.997

Pi Running Raspbian:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+124.109.2.169   122.155.169.213  3 u  500 1024  257   55.963   -3.992  24.100
*103.22.182.121  202.47.249.20    2 u  162 1024  265   40.893  -20.743  32.951

Vero running OSMC:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*x2204.ipv9.xyz  202.47.249.21    2 u  125 1024  247   99.905    6.429  37.642
+203.158.247.150 131.214.52.161   3 u 2017 1024  376   99.748   19.287  17.911

Mac running El Capitan

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*sgsin3-ntp-002. .GPSs.           1 u   36   64  377   71.706    0.904  52.565

It took almost ten seconds for the Pi running OSMC to respond to the query. All three other machines were almost instant. The time on this machine was correct when the query was done.

I have enabled debugging for ntp and have restarted the ntp service.

Iā€™m afraid I donā€™t have much for you. After enabling ntp logging the Pi started crashing. Oddly, after enabling ntp logging I never again saw the time errors. Instead the Pi just crashes. I have no idea if the two are related.

I doubt these will be much use, but, as request:

osmc@OSMCBR:~$ paste-log /var/log/ntpstats/peerstats
http://paste.osmc.io/miwiwevuqi
osmc@OSMCBR:~$ paste-log /var/log/ntpstats/loopstats
http://paste.osmc.io/ekuketaluk
osmc@OSMCBR:~$ paste-log ntp.log
http://paste.osmc.io/nekaceyafu
osmc@OSMCBR:~$ sudo journalctl | paste-log
http://paste.osmc.io/oyupovidog

ntp.log is just the output of this:

osmc@OSMCBR:~$ ntpq -c peers >> ntp.log

I have now disabled ntp logging.

Any idea why journalcrl jumps from October 28th to November 5th?

Oct 28 14:05:11 OSMCBR sudo[464]: pam_unix(sudo:session): session opened for user root by osmc(uid=0)
Nov 05 05:49:40 OSMCBR systemd[427]: Time has been changed

Sorry I couldnā€™t be more helpful.

What do you mean by crash exactly, do you mean you canā€™t even log in with SSH after the crash, or is it just Kodi crashing ?

If you are getting a hard freeze then you almost certainly have some hardware instability that needs solving. You need to check the power adaptor, SD card, and it may be worth doing a fresh install as well.

Thereā€™s not much point trying to troubleshoot a subtle issue like the time being wrong if the whole system is unstable - you should not be getting a system freeze just because you enabled ntp debugging, linux is not unstable in that wayā€¦

Itā€™s a hard freeze requiring a power cycle.

But, now that Iā€™ve disabled ntp logging it doesnā€™t freeze anymore.

I agree that this is consuming way too much effort and time for what is a minor issue.

Letā€™s stop.

I have no problem helping you get to the bottom of the time issue, but if the system is unstable then that instability could be the cause of the issue, leading to us running around in circles looking for a bug that doesnā€™t exist. At the very least it will hinder any troubleshooting.

Have you tried a different power adaptor ? I still see in your log that http-time is unable to connect during boot, while I initially thought that may be a network issue I now wonder (after seeing system instability) whether this is a power related issue, as the CPU is very busy during boot which puts it in Turbo mode, increases the power requirements, and can cause the Ethernet port to stop working temporarily.

Could you try running the following command via SSH after it has booted to see if it is able to set the date ?

sudo /usr/bin/http-time

You should see something like:

osmc@rpi2:~$ sudo /usr/bin/http-time
Updated time from Thu Nov  5 10:58:34 UTC 2015 to Thu Nov  5 10:58:34 UTC 2015 using HTTP query to www.google.com

If it fails try it a few times to see if it always fails. It would be interesting to see whether this fails or succeeds when run after booting up. If this does succeed when run manually, and coupled together with a general instability I would be suspicious of the power supply to the Pi.

Nope, Iā€™m done.

Reminds me of my ISP. I was having horrible problems with my ADSL connection being unstable. They insisted it was my router and refused to do a service visit until I bought a new one. So, I bought a new one. The problems persisted. They came out and switched cable pairs and the ADSL instability disappeared.

So, I bought a new router for nothing.

I put the old ā€œbadā€ one in my beach condo where it continues to perform flawlessly.

The power supply on my Pi was purchased from the official Raspberry Pi organization. I only bought it because someone here insisted that the one I was using must be bad.

Th ā€œbadā€ power supply continues to perform well on a different Pi running my web cam under Raspbian.

If you want to give up on it fair enough.

However as far as Iā€™m concerned your system is unstable - I can tell you as a fact from nearly 20 years using Linux that there is no way that just enabling debug logging for ntp is going to cause hard system freezes unless there is an underlying instability issue with the system, and almost certainly a hardware related issue.

Until you figure out what that issue is and fix it out you are going to continue to have problems with this system. Youā€™ve already said that you have another system running OSMC that does not have any problems with setting the time, that alone should make it obvious that there is a problem with this system.

I wish you the best in fixing it.

1 Like

Vero running OSMC. Always fails:

osmc@osmc:~$ sudo /usr/bin/http-time
No internet connection was available within 60 seconds, giving up.

Pi running OSMC. Always fails:

osmc@OSMCBR:~$ sudo /usr/bin/http-time
No internet connection was available within 60 seconds, giving up.

So what do you get if you manually do

wget --server-response --timeout=4 --max-redirect 0 --spider www.google.com

and

wget --server-response --timeout=4 --max-redirect 0 --spider www.microsoft.com

And what does this report ?

connmanctl state

It should show something like:

  State = online
  OfflineMode = False
  SessionMode = False

This is how the http-time script checks to see if it has a working internet connection.

Pi running OSMC:

osmc@OSMCBR:~$ wget --server-response --timeout=4 --max-redirect 0 --spider www.google.com
Spider mode enabled. Check if remote file exists.
--2015-11-06 04:34:49--  http://www.google.com/
Resolving www.google.com (www.google.com)... failed: Connection timed out.
wget: unable to resolve host address ā€˜www.google.comā€™
osmc@OSMCBR:~$ connmanctl state
  State = ready
  OfflineMode = False
  SessionMode = False
osmc@OSMCBR:~$ ping www.google.com
PING www.google.com (110.164.16.29): 56 data bytes
64 bytes from 110.164.16.29: seq=0 ttl=58 time=235.401 ms
64 bytes from 110.164.16.29: seq=1 ttl=58 time=286.583 ms
64 bytes from 110.164.16.29: seq=2 ttl=58 time=121.853 ms
^C
--- www.google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 121.853/214.612/286.583 ms

osmc@OSMCBR:~$ ping www.mgnewman.com
PING www.mgnewman.com (124.217.255.131): 56 data bytes
64 bytes from 124.217.255.131: seq=0 ttl=51 time=167.643 ms
64 bytes from 124.217.255.131: seq=1 ttl=51 time=170.601 ms
64 bytes from 124.217.255.131: seq=2 ttl=51 time=122.568 ms
64 bytes from 124.217.255.131: seq=3 ttl=51 time=197.479 ms
64 bytes from 124.217.255.131: seq=4 ttl=51 time=135.255 ms
^C
--- www.mgnewman.com ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 122.568/158.709/197.479 ms

Vero running OSMC

osmc@osmc:~$ wget --server-response --timeout=4 --max-redirect 0 --spider www.google.com
Spider mode enabled. Check if remote file exists.
--2015-11-06 04:34:59--  http://www.google.com/
Resolving www.google.com (www.google.com)... failed: Connection timed out.
wget: unable to resolve host address ā€˜www.google.comā€™
osmc@osmc:~$ connmanctl state
  State = ready
  OfflineMode = False
  SessionMode = False
osmc@osmc:~$ ping www.mgnewman.com
PING www.mgnewman.com (124.217.255.131): 56 data bytes
64 bytes from 124.217.255.131: seq=0 ttl=51 time=199.583 ms
64 bytes from 124.217.255.131: seq=1 ttl=51 time=238.691 ms
64 bytes from 124.217.255.131: seq=2 ttl=51 time=148.201 ms
64 bytes from 124.217.255.131: seq=3 ttl=51 time=276.202 ms
64 bytes from 124.217.255.131: seq=5 ttl=51 time=290.441 ms
64 bytes from 124.217.255.131: seq=6 ttl=51 time=136.361 ms
^C
--- www.mgnewman.com ping statistics ---
7 packets transmitted, 6 packets received, 14% packet loss
round-trip min/avg/max = 136.361/214.913/290.441 ms

Mac running 10.11.1

Bleach:~ mnewman$ wget --server-response --timeout=4 --max-redirect 0 --spider www.google.com
Spider mode enabled. Check if remote file exists.
--2015-11-06 04:37:39--  http://www.google.com/
Resolving www.google.com (www.google.com)... 110.164.12.212, 110.164.12.222, 110.164.12.217, ...
Connecting to www.google.com (www.google.com)|110.164.12.212|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: http://www.google.co.th/?gws_rd=cr&ei=JMw7VsfhLsi70gT1roeQBA
  Cache-Control: private
  Content-Type: text/html; charset=UTF-8
  P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
  Date: Thu, 05 Nov 2015 21:37:40 GMT
  Server: gws
  Content-Length: 261
  X-XSS-Protection: 1; mode=block
  X-Frame-Options: SAMEORIGIN
  Set-Cookie: PREF=ID=1111111111111111:FF=0:TM=1446759460:LM=1446759460:V=1:S=k0vyPDDPF3U3eJn1; expires=Thu, 31-Dec-2015 16:02:17 GMT; path=/; domain=.google.com
  Set-Cookie: NID=73=VddletFKwChCEG5762hYVAaDB9u47QGl0AFYLnNKs4iwcY6E_ar4-qmCv0i1PVnVpV0f3cGDhsxYSQ8fxsIF1-Bd_2ahyQiBjZOdlgh79Y0HoFiP5VsVy8YxWd7LjA9pttGL1GIL15b5F1CqVl-Ht5zEVye1Zcc; expires=Fri, 06-May-2016 21:37:40 GMT; path=/; domain=.google.com; HttpOnly
Location: http://www.google.co.th/?gws_rd=cr&ei=JMw7VsfhLsi70gT1roeQBA [following]
0 redirections exceeded.

Pi running Raspbian

pi@rasp ~/webcam $ wget --server-response --timeout=4 --max-redirect 0 --spider www.google.com
converted 'http://www.google.com' (ISO-8859-1) -> 'http://www.google.com' (UTF-8)
Spider mode enabled. Check if remote file exists.
--2015-11-06 04:40:21--  http://www.google.com/
Resolving www.google.com (www.google.com)... 110.164.16.114, 110.164.16.98, 110.164.16.104, ...
Connecting to www.google.com (www.google.com)|110.164.16.114|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: http://www.google.co.th/?gws_rd=cr&ei=xsw7Vvj5GoOZ0gSoh5OoDw
  Cache-Control: private
  Content-Type: text/html; charset=UTF-8
  P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
  Date: Thu, 05 Nov 2015 21:40:22 GMT
  Server: gws
  Content-Length: 261
  X-XSS-Protection: 1; mode=block
  X-Frame-Options: SAMEORIGIN
  Set-Cookie: PREF=ID=1111111111111111:FF=0:TM=1446759622:LM=1446759622:V=1:S=HQHvJnC6NBMvmI6f; expires=Thu, 31-Dec-2015 16:02:17 GMT; path=/; domain=.google.com
  Set-Cookie: NID=73=bcOCRbsObzxCqpMIpFWAHE4LaCHJvTPnEGdNR9luW4qHgiryg5wFcBwiU56iJsqB4D2_6OE1SfN7yU9EtbRIbrvpwAAud-KMHLYXENyY2hwtlwaNSH1g_tiOTNvCt6YDGLW_hA6QfalRph1plFoW9CjcwCXVKgs; expires=Fri, 06-May-2016 21:40:22 GMT; path=/; domain=.google.com; HttpOnly
Location: http://www.google.co.th/?gws_rd=cr&ei=xsw7Vvj5GoOZ0gSoh5OoDw [following]
converted 'http://www.google.co.th/?gws_rd=cr&ei=xsw7Vvj5GoOZ0gSoh5OoDw' (ISO-8859-1) -> 'http://www.google.co.th/?gws_rd=cr&ei=xsw7Vvj5GoOZ0gSoh5OoDw' (UTF-8)
0 redirections exceeded.

Hi Michael,

I hope you are well

You are experiencing networking (potentially DNS) related issues, and odd ones at that. On your Pi 1, you had issues with wget connecting to Google but moments later were able to ping. State="ready" infers that while your link is established, your ability to connect to the Internet is yet to be determined (the connection manager canā€™t reach ipv4.online.osmc.io).

This is either an ISP issue or a problem with DNS. The quickest way to resolve this issue is to do as follows:

  • Edit /etc/hosts (sudo nano)
  • Add the following entries
178.62.84.106 ipv4.online.osmc.io (for reliable Connection Status)
139.162.18.76 apt.osmc.tv (for reliable downloads in Asia)

(brackets are comments, donā€™t include)

Now edit, /usr/bin/httpd-time and change www.google.com to 139.162.18.76.

@DBMandrake: Need to patch ConnMan to use FallbackNameservers. Also propose using Mirror Director for time resolution.

Looks like slow DNS servers to me. After a reboot (to clear the DNS cache) try:

time wget --server-response --timeout=20 --max-redirect 0 --spider www.google.com

To see how many seconds it takes to resolve - obviously more than 4 seconds if it was timing out after 4 seconds before.

What DNS servers are allocated in /etc/resolv.conf and are the same DNS servers you have allocated on your Mac ?

EG do you use DHCP for all machines or are some using a static configuration ?

Edit: I have a pretty good idea of what it probably is - please provide a copy of /etc/resolv.conf both from your Pi and from your Mac.

There is a known bug in OSMC at the moment that the order of dns servers in /etc/resolv.conf is reversed from what it should be so if you have a primary and secondary server allocated and the secondary sever doesnā€™t work or is slow OSMC is trying to use that faulty secondary server first while your other OSā€™s like Mac OS will be using the correct primary server.

Very clever.

Sam

So many questions:

@sam - I made the changes you suggested to the hosts and http-time files and still get the same timeout when running http-time.

@DBMandrake

osmc@OSMCBR:/usr/bin$ cat /etc/resolv.conf
# Generated by Connection Manager
nameserver 110.164.252.222
nameserver 8.8.4.4

Bleach:~ mnewman$ cat /etc/resolv.conf
#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
#
# This file is automatically generated.
#
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 192.168.0.1

All the machines on my LAN have static IP addresses (except for guests)

After reboot:

osmc@OSMCBR:~$ time wget --server-response --timeout=20 --max-redirect 0 --spider www.google.com
Spider mode enabled. Check if remote file exists.
--2015-11-06 05:46:26--  http://www.google.com/
Resolving www.google.com (www.google.com)... 110.164.6.232, 110.164.6.236, 110.164.6.231, ...
Connecting to www.google.com (www.google.com)|110.164.6.232|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: http://www.google.co.th/?gws_rd=cr&ei=Qtw7VvTPOaixmwXmmY6wAQ
  Cache-Control: private
  Content-Type: text/html; charset=UTF-8
  P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
  Date: Thu, 05 Nov 2015 22:46:26 GMT
  Server: gws
  Content-Length: 261
  X-XSS-Protection: 1; mode=block
  X-Frame-Options: SAMEORIGIN
  Set-Cookie: PREF=ID=1111111111111111:FF=0:TM=1446763586:LM=1446763586:V=1:S=0C2VYsDk5aeHQJEB; expires=Thu, 31-Dec-2015 16:02:17 GMT; path=/; domain=.google.com
  Set-Cookie: NID=73=McO3VLwOzjFyLnSluE5zlYCg-39aiAwWElO2YFRGW5cBlY51zi8BKms5eh3KfkFHpbGFQo5kRQca2YV9fqIF-SVoIdXjdFKTtW9xPlXAlAPF7QuH22k90WDvzP2FS0T_kXM_qKGf829V4fLAbOUf-0TzTU3R8w; expires=Fri, 06-May-2016 22:46:26 GMT; path=/; domain=.google.com; HttpOnly
Location: http://www.google.co.th/?gws_rd=cr&ei=Qtw7VvTPOaixmwXmmY6wAQ [following]
0 redirections exceeded.

real	0m1.059s
user	0m0.040s
sys	0m0.040s

==

osmc@OSMCBR:~$ sudo http-time
Updated time from Thu Nov  5 22:49:04 UTC 2015 to Thu Nov  5 22:49:05 UTC 2015 using HTTP query to 139.162.18.76

Let me know if I failed to do anything requested. Itā€™s very early in the morning hereā€¦.

I notice that you have completely different namesevers on OSMC and your Mac - any particular reason for that ? On OSMC you have:

nameserver 110.164.252.222
nameserver 8.8.4.4

On the Mac you have:

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 192.168.0.1

Is 110.164.252.222 provided by your ISP ?

I would try changing OSMC to use Google DNS only (8.8.8.8 and 8.8.4.4) and see how you go. I suspect that 110.164.252.222 is causing your problems.

If this is the case you should be able to remove the /etc/hosts entries Sam suggested.