Sometimes, mender-connect fails to reach the server. After a while, it suddenly works, and sometimes a reboot works. Restarting the mender-connect.service also seems to work.
The error message in the log is *connection manager failed to connect to https://hosted.mender.io/api/devices/v1/deviceconnect/connect: websocket: bad handshake; reconnecting in 5s (try 212/0); len(token)=873
- Raspberry CM3+, Raspbian Buster
- mender-convert installed by running script
wget -q -O- https://get.mender.io/ | sudo bash -s
- mender software (by apt list):
mender-client/unknown,now 2.5.0-1 armhf [installed]
mender-connect/unknown,now 1.0.0-1 armhf [installed]
Contents of the /etc/mender/mender-connect.conf
configruation (default conf.)
{
"ServerCertificate": "/usr/share/doc/mender-client/examples/demo.crt",
"User": "someuser",
"ShellCommand": "/bin/bash"
}
sudo journalctl -u mender-connect -f
gives the following output:
Mar 19 16:31:42 somename mender-connect[733]: time="2021-03-19T16:31:42+01:00" level=info msg="Issuer: [], Valid from: 2016-12-14 19:52:46 +0000 UTC, Valid to: 2026-12-12 19:52:46 +0000 UTC"
Mar 19 16:31:43 somename mender-connect[733]: time="2021-03-19T16:31:43+01:00" level=error msg="connection manager failed to connect to https://hosted.mender.io/api/devices/v1/deviceconnect/connect: websocket: bad handshake; reconnecting in 5s (try 211/0); len(token)=873"
Mar 19 16:31:48 somename mender-connect[733]: time="2021-03-19T16:31:48+01:00" level=info msg="loadServerTrust loading certificate from /usr/share/doc/mender-client/examples/demo.crt"
Mar 19 16:31:48 somename mender-connect[733]: time="2021-03-19T16:31:48+01:00" level=info msg="API Gateway certificate (in PEM format): \n-----BEGIN CERTIFICATE-----\nMIIBf...AXBgNVBAMM=\n-----END CERTIFICATE-----\n"
Mar 19 16:31:48 somename mender-connect[733]: time="2021-03-19T16:31:48+01:00" level=info msg="Issuer: [], Valid from: 2016-12-14 19:52:46 +0000 UTC, Valid to: 2026-12-12 19:52:46 +0000 UTC"
Mar 19 16:31:49 somename mender-connect[733]: time="2021-03-19T16:31:49+01:00" level=error msg="connection manager failed to connect to https://hosted.mender.io/api/devices/v1/deviceconnect/connect: websocket: bad handshake; reconnecting in 5s (try 212/0); len(token)=873"
Mar 19 16:31:54 somename mender-connect[733]: time="2021-03-19T16:31:54+01:00" level=info msg="loadServerTrust loading certificate from /usr/share/doc/mender-client/examples/demo.crt"
Mar 19 16:31:54 somename mender-connect[733]: time="2021-03-19T16:31:54+01:00" level=info msg="API Gateway certificate (in PEM format): \n-----BEGIN CERTIFICATE-----\nMIIBf...AXBgNVBAMM=\n-----END CERTIFICATE-----\n"
Question: Is there anything I can do, or is it just a software bug?
Update (2021.03.20)
I suspected the time to be an issue (checken and egg with ntpd and resolved) when booting with a time/date off by several hours. I tried to recreate the situation by stopping resolved, timesynced and flushing dns), but I cannot re-recreate the situation:
sudo systemctl stop systemd-timesyncd.service
sudo systemctl stop mender-connect.service
sudo systemctl stop systemd-resolved
sudo systemd-resolve --flush-caches
sudo date +%Y%m%d -s"20210319"
sudo systemd-resolve --flush-caches
ping vg.no
sudo reboot
The situation usually occurs after a fresh image installation (or artifact update).