INFO disconnect from server
# help
d
I get this error a few times a day. When it happens the device stops sending data and I have to restart it to get it to work again. Max offline is set to 1m. What could be causing this?
f
Is this "INFO: disconnect from server" in the logs of the console?
Is there any other useful information?
If not, could you maybe run the device with USB and
toit monitor
connected to see if the serial output has more information?
d
It is in a remote location, so I don't think I can do that.
Yes, it is from the logs of the console. Everything else looks normal in the console before it happens.
f
Another good way of getting the information would be to use an SD card logger to save the UART output on an SD card.
I'm looking through our code now, to see if I can find a hint of why the device would disconnect.
So far I can't find the place where "disconnect from server" could come from.
Is this something that used to be stable, but degraded, or did you see this message from the beginning?
Also: the "INFO: ..." line has a column that says which application was responsible for it. In your screenshot that's cut off. Could you provide it too?
d
It used to be more stable, but degraded.
Let me just find it.
f
The first screenshot is cut off, but it looks like the message comes from the 'OptiToit' program. At least the first pixels could be an "O". In that case, could you look in your application if you can find the "disconnect from server"?
Otherwise, could it be a message from a library/package your app uses?
Could this, for example, be a message from the MQTT library?
d
There is nothing that says "disconnect from server" in the program. It could be from a library though
f
Which libraries/packages do you use in that program? (or at least which ones could be candidates? MQTT is the first that comes to mind).
d
import gpio import pubsub import encoding.json import i2c import monitor import net import net.x509 as net import http import tls import certificate_roots import bme280 import mqtt
Those are all the libraries used in the program
f
Could be the MQTT one.
I need to leave now, but will be back in ~1h. Maybe you can try to find places where to add debug information in your program.
d
That's ok. I will take a look at the mqtt library
Yep I just found it in the mqtt library
full_client.toit line 801
f
This means that the server disconnected the client.
When you say "stops sending data" and you "have to restart it".
Do you mean that the device is completely offline, or just that the program isn't responding anymore?
I interpreted it as, the device can't be reached anymore, but from the description it sounds like it's just that the program is not connected to the MQTT broker anymore.
Could you give me the version of the MQTT package you are using?
It's written in
package.lock
.
d
I just mean the program isn't responding anymore. I can reboot it through the console.
MQTT version is 2.0.4
f
If you can reboot it through the console, then the device is still responding.
When you "the program isn't responding" I guess you mean it's not responding to messages through MQTT.
The MQTT package has been changed to be more aggressive in trying to reconnect. However, starting with 2.1.0 it's only v2.
I'm preparing a new release now that should also work on Toit v1. Once you have upgraded to that one, the client should automatically reconnect.
d
Ok, thanks. When will the new release for Toit v1 be ready?
f
PRs for the MQTT package are under review. I then only need to cut a new MQTT release.
The package should be released. You can run
toit pkg update
to update it.
Let me know if there are issues.