Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mosquitto-dev] clarity on disconnect reasons

After what feels like over a year of maintaining the pkgsrc entry for
moquitto, I've started to actually use it.

My setup is very simple:

  mosquitto running on a system, with TLS but otherwise pretty default

  esp8266 with nodemcu (not near the broker, and through a NAT), my own
  lua code, temp/humidity sensor, connecting once with 1 min keepalive
  and lwt set to online=OFF, posting online=ON, then posting T/H every
  minute.

  home assistant running (also not near the broker), watching some
  topics, and in particular sending alerts on oneline=OFF.

After days of just collecting data, I got a "power off alert" (which of
course really means "the sensor has gone offline, so either power is
off, the net is broken, the hardware has flaked, or some code is
buggy").  The logs showed:

  Sep 11 06:31:01 foo  mosquitto[8167]: Socket error on client esp8266-bar, disconnecting.
  Sep 11 06:31:10 [new connection]

which is curious.  There was a second pair around 2130 on the 10th, 12
seconds apart.  It takes about 18s between boot and posting the online
message (I have a 10s delay in init.lua before loading the rest, to
allow recovery from bad code without reflashing, and the rest is boot,
joining wifi, mqtt connection including tls), so the reboot must have
been 06:30:52 ish.

So, I am guessing that something happened in the network, and there is
an odd entry in the dns server log at about the same time.  All
reconnected, and overall things are working as intended.

But, it would be nice if "socket error" were more specific, giving which
system call and the errno value, and perhaps even why the system call
was made.  I am guessing it was a server-originated keepalive
transmission that got back a RST because the device had not TCP
connection open.


Back to the top