Skip to content

Commit

Permalink
fix: allow mqtt client to reconnect if it gets disconnected (#977)
Browse files Browse the repository at this point in the history
MQTT client reconnections were disabled for seemingly no reason.
Combined with the fact that the SocketClient's various error and
disconnection events were completely ignored, a random disconnection
before the expected final message was received would almost certainly
cause the CLI to essentially hang, doing nothing until the failsafe
timeout (currently 10m) hit.

There is an additional edge case which is not covered by this
change. Even now that reconnections are enabled, in the unlucky case
that the final message is distributed when our client is not connected
(i.e. in the process waiting to reconnect, or actively reconnecting),
then we'll still miss it and hang the same way. To reduce the odds
of this edge condition happening, the reconnect wait timeout was
reduced to 100ms from the default of 1000ms.
  • Loading branch information
sorccu authored Nov 7, 2024
1 parent 7bab6a2 commit bb421ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cli/src/services/socket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SocketClient {
const accountId = config.getAccountId()
const apiKey = config.getApiKey()
const options: mqtt.IClientOptions = {
reconnectPeriod: 0,
reconnectPeriod: 100,
username: accountId,
password: apiKey,
}
Expand Down

0 comments on commit bb421ba

Please sign in to comment.