Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MQTT resubscription on reconnect (#19)
MQTT.js contains logic to automatically reconnect to the broker if the connection is lost, and to automatically resubscribe any subscriptions if this new connection doesn't resume the previous session. Consuming clients rely on this behaviour. Unfortunately, the code in the GSS client implementation, which bypassed the automatic reconnection in favour of manual reconnection in order to fetch a new Kerberos authentication packet, was causing the auto-re-subscription to be bypassed. Instead, fetch a new authenticator on "close", but allow the auto-reconnect to still function. There is a race here; it is possible we will attempt to reconnect before we have fresh credentials. This cannot be avoided with the current MQTT.js API. In this case the connect attempt will fail and we will retry; a second authenticator fetch immediately after the first should succeed immediately, as we have a service ticket so it's just crypto and no network traffic.
- Loading branch information