Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app-shell): reduce latency when switching between MQTT clients
Each network interface is tied to a specific IP, and the app-shell uses this IP to communicate with MQTT. If a client manually disconnects from a network interface, some network interfaces on some robots (such as the USB on the OT-2) do not fire the MQTT 'error' or 'disconnect' events immediately. This means that the app-shell thinks it's still connected to MQTT until the keepAlive packet receives no response. The MQTT standard keepalive (and what we currently use) is 60 seconds. After the packet is sent, there is a connectTimeout that the server has to respond before the client fires the 'disconnect' event. After a client disconnects, the app-shell will attempt to connect to the same robot on a different IP if available. This scenario shouldn't affect most users in most circumstances, but there is one rather simple improvement we can make that sometimes reduces this latency - MQTT has an 'offline' event. Some network interfaces cause the 'offline' event to fire, and we can immediately end the client (and reestablish a new MQTT connection on a different network interface if available).
- Loading branch information