Skip to content

Commit

Permalink
add randomised start call delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mcl authored Sep 9, 2024
1 parent 8b1c63f commit 22ae18b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/agent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { IntervalJitter } = require('./IntervalJitter')
const { existsSync } = require('fs')
const { randomInt } = require('crypto')
const fs = require('fs/promises')
const path = require('path')
const httpClient = require('./http')
Expand Down Expand Up @@ -135,6 +136,8 @@ class Agent {
}
// We have been provided a broker URL to use
this.mqttClient = mqttClient.newMQTTClient(this, this.config)
// Wait a short random delay to reduce stress on broker when large numbers of devices come on-line

Check failure on line 139 in lib/agent.js

View workflow job for this annotation

GitHub Actions / build (16)

Trailing spaces not allowed
await new Promise(r => setTimeout(r, randomInt(20, 5000)));

Check failure on line 140 in lib/agent.js

View workflow job for this annotation

GitHub Actions / build (16)

Promise constructor parameters must be named to match "^_?resolve$"

Check failure on line 140 in lib/agent.js

View workflow job for this annotation

GitHub Actions / build (16)

Extra semicolon
this.mqttClient.start()
this.mqttClient.setApplication(this.currentApplication)
this.mqttClient.setProject(this.currentProject)
Expand Down

0 comments on commit 22ae18b

Please sign in to comment.