Hello there,
I’m controlling my FarmBot via Python and MQTT sending rpc requests with movement commands formatted as CeleryScript.
After I publish a command using Paho MQTT library, QoS 0 and TLS, I wait for the
corresponding rpc_ok message to continue sending further commands.
When monitoring the from_device and from_clients topics, everything looks okay.
Like this:
Incoming MQTT messages:
bot/device_XXXX/from_clients b’{“kind”: “rpc_request”, “args”: {“label”: “2db2d145-c5c1-48e9-bb23-29005fabba4c”}, “body”: [{“kind”: “move_relative”, “args”: {“x”: 200, “y”: 0, “z”: 0, “speed”: 100}}]}’
Incoming MQTT messages:
bot/device_XXXX/from_device b’{“args”:{“label”:“2db2d145-c5c1-48e9-bb23-29005fabba4c”},“kind”:“rpc_ok”}’
Incoming MQTT messages:
bot/device_XXXX/from_clients b’{“kind”: “rpc_request”, “args”: {“label”: “0b2a276a-afd1-4caa-a2a9-2539fcf58ba1”}, “body”: [{“kind”: “move_absolute”, “args”: {“location”: {“kind”: “coordinate”, “args”: {“x”: 580, “y”: 650, “z”: -250}}, “speed”: 100, “offset”: {“kind”: “coordinate”, “args”: {“x”: 0, “y”: 0, “z”: 0}}}}]}’
Incoming MQTT messages:
bot/device_XXXX/from_device b’{“args”:{“label”:“9f73fb90-a0f3-4275-b6fa-22b8e9ca5e8f”},“kind”:“rpc_ok”}’
But I ran into random connection issues. At some times I got disconnected from the MQTT broker. When monitoring the connection with Wireshark I can see only a TCP reset from the broker as seen in the screenshot:
It seems to be a network related issue since the connection just crashes. After about 8 minutes the MQTT client reconnects. I tested it on Ubuntu 19.10, Ubuntu 19.4 with both paho mqtt version 1.4 and 1.5. and the MQTT.fx client.
The FarmBot is connected via ethernet.
Re-creating an API token every time didn’t change anything so I stick with the existing one which valid for 40 days. Adjusting the MQTT keepalive value in any ranges from 10 to 60 seconds also didn’t do the trick.
Any advice is appreciated.