guild icon
Toit
#INFO disconnect from server
Thread channel in help
DunjinnLord
DunjinnLord 12/13/2022 01:17 PM
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?
floitsch
floitsch 12/13/2022 01:20 PM
Is this "INFO: disconnect from server" in the logs of the console?
floitsch
floitsch 12/13/2022 01:21 PM
Is there any other useful information?
floitsch
floitsch 12/13/2022 01:21 PM
If not, could you maybe run the device with USB and toit monitor connected to see if the serial output has more information?
DunjinnLord
DunjinnLord 12/13/2022 01:22 PM
It is in a remote location, so I don't think I can do that.
DunjinnLord
DunjinnLord 12/13/2022 01:23 PM
Yes, it is from the logs of the console. Everything else looks normal in the console before it happens.
floitsch
floitsch 12/13/2022 01:25 PM
Another good way of getting the information would be to use an SD card logger to save the UART output on an SD card.
floitsch
floitsch 12/13/2022 01:25 PM
I'm looking through our code now, to see if I can find a hint of why the device would disconnect.
floitsch
floitsch 12/13/2022 01:27 PM
So far I can't find the place where "disconnect from server" could come from.
floitsch
floitsch 12/13/2022 01:30 PM
Is this something that used to be stable, but degraded, or did you see this message from the beginning?
floitsch
floitsch 12/13/2022 01:31 PM
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?
(edited)
DunjinnLord
DunjinnLord 12/13/2022 01:32 PM
It used to be more stable, but degraded.
DunjinnLord
DunjinnLord 12/13/2022 01:32 PM
Let me just find it.
DunjinnLord
DunjinnLord 12/13/2022 01:35 PM
floitsch
floitsch 12/13/2022 01:37 PM
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"?
floitsch
floitsch 12/13/2022 01:37 PM
Otherwise, could it be a message from a library/package your app uses?
floitsch
floitsch 12/13/2022 01:38 PM
Could this, for example, be a message from the MQTT library?
DunjinnLord
DunjinnLord 12/13/2022 01:40 PM
There is nothing that says "disconnect from server" in the program. It could be from a library though
floitsch
floitsch 12/13/2022 01:42 PM
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).
DunjinnLord
DunjinnLord 12/13/2022 01:42 PM
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
DunjinnLord
DunjinnLord 12/13/2022 01:42 PM
Those are all the libraries used in the program
floitsch
floitsch 12/13/2022 01:45 PM
Could be the MQTT one.
floitsch
floitsch 12/13/2022 01:46 PM
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.
DunjinnLord
DunjinnLord 12/13/2022 01:48 PM
That's ok. I will take a look at the mqtt library
DunjinnLord
DunjinnLord 12/13/2022 01:52 PM
Yep I just found it in the mqtt library
DunjinnLord
DunjinnLord 12/13/2022 01:53 PM
full_client.toit line 801
floitsch
floitsch 12/13/2022 03:22 PM
This means that the server disconnected the client.
DunjinnLordOPDunjinnLord
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 ...
floitsch
floitsch 12/13/2022 03:22 PM
When you say "stops sending data" and you "have to restart it".
floitsch
floitsch 12/13/2022 03:22 PM
Do you mean that the device is completely offline, or just that the program isn't responding anymore?
floitsch
floitsch 12/13/2022 03:23 PM
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.
floitsch
floitsch 12/13/2022 03:23 PM
Could you give me the version of the MQTT package you are using?
floitsch
floitsch 12/13/2022 03:23 PM
It's written in package.lock.
DunjinnLord
DunjinnLord 12/13/2022 04:02 PM
I just mean the program isn't responding anymore. I can reboot it through the console.
DunjinnLord
DunjinnLord 12/13/2022 04:02 PM
MQTT version is 2.0.4
floitsch
floitsch 12/13/2022 04:16 PM
If you can reboot it through the console, then the device is still responding.
floitsch
floitsch 12/13/2022 04:16 PM
When you "the program isn't responding" I guess you mean it's not responding to messages through MQTT.
floitsch
floitsch 12/13/2022 04:18 PM
The MQTT package has been changed to be more aggressive in trying to reconnect.
However, starting with 2.1.0 it's only v2.
floitsch
floitsch 12/13/2022 05:26 PM
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.
DunjinnLord
DunjinnLord 12/14/2022 08:47 AM
Ok, thanks. When will the new release for Toit v1 be ready?
floitsch
floitsch 12/14/2022 09:43 AM
PRs for the MQTT package are under review. I then only need to cut a new MQTT release.
floitsch
floitsch 12/15/2022 02:38 PM
The package should be released.
You can run toit pkg update to update it.
floitsch
floitsch 12/15/2022 02:38 PM
Let me know if there are issues.
42 messages in total