Skip to content

Commit

Permalink
Fixed keepAlive default to 5 (seconds), mqtt library update to avoid …
Browse files Browse the repository at this point in the history
…a keepAlive 1 issue with paho.mqtt (#20)

* Fixed keepAlive default to 5 (seconds), sanitized some docs
* updated dependency to paho mqtt library to version 1.4.3 (fixes an issue with keepAlive 1)
  • Loading branch information
jforge authored Jun 24, 2024
1 parent 41876fb commit 7e43d80
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ Here are a few methods of running the image in a Kubernetes cluster
### Running the load generator

```bash
kubectl run mqtt-load-generator --image=jforge/mqtt-load-generator \
kubectl run mqtt-load-generator --image=ghcr.io/pablitovicente/mqtt-load-generator:v1.0.7 \
-- -h <mqtt-broker-address> -p 1883 -u secret -P mega_secret \
-c 1000 -s 1000 -t /golang/pub -i 1 -n 100
```


### Running the load checker

```bash
kubectl run mqtt-load-checker --image=pgschk/mqtt-load-generator --command \
kubectl run mqtt-load-checker --image=ghcr.io/pablitovicente/mqtt-load-generator:v1.0.7 --command \
-- /checker -h <mqtt-broker-address> -p 1883 -u secret -P mega_secret \
-t /golang/pub --disable-bar
```
Expand Down
6 changes: 3 additions & 3 deletions cmd/checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ func main() {
password := flag.String("P", "", "MQTT password")
host := flag.String("h", "localhost", "MQTT host")
port := flag.Int("p", 1883, "MQTT port")
qos := flag.Int("q", 1, "MQTT QoS used by all clients")
qos := flag.Int("q", 1, "MQTT QoS level used by all clients")
disableBar := flag.Bool("disable-bar", false, "Disable interactive mode to display statistics as log messages instead of interactive output")
resetTime := flag.Float64("reset-after", 30, "Reset counter after <n> seconds without a message")
cert := flag.String("cert", "", "Path to TLS certificate file")
ca := flag.String("ca", "", "Path to TLS CA file")
key := flag.String("key", "", "Path to TLS key file")
key := flag.String("key", "", "Path to TLS private key file")
insecure := flag.Bool("insecure", false, "Set to true to allow self signed certificates")
mqtts := flag.Bool("mqtts", false, "Set to true to use MQTTS")
cleanSession := flag.Bool("cleanSession", true, "Set to true for clean MQTT sessions or false to keep session")
clientID := flag.String("clientID", "", "Custom MQTT clientID")
keepAliveTimeout := flag.Int64("keepAliveTimeout", 5000, "Set the amount of time (in seconds) that the client should wait before sending a PING request to the broker")
keepAliveTimeout := flag.Int64("keepAliveTimeout", 5, "Set the amount of time (in seconds) the client should wait for, before sending a PING request to the broker")

flag.Parse()

Expand Down
8 changes: 4 additions & 4 deletions cmd/load_generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ func main() {
messageCount := flag.Int("c", 1000, "Number of messages to send")
messageSize := flag.Int("s", 100, "Size in bytes of the message payload")
interval := flag.Int("i", 1, "Milliseconds to wait between messages")
schedule := flag.String("z", "normal", "Distribution of time between messages: 'flat': always wait Interval between messages, 'normal': wait a random amount between messages with mean equal to the interval and stdev to half interval, 'random': wait a random amount between messages with mean equal to the interval.")
schedule := flag.String("z", "normal", "Distribution of time between messages: 'flat': always wait interval between messages, 'normal': wait a random amount between messages with mean equal to the interval and stdev to half the interval, 'random': wait a random amount between messages with mean equal to the interval.")
targetTopic := flag.String("t", "/load", "Target MQTT topic to publish messages to")
username := flag.String("u", "", "MQTT username")
password := flag.String("P", "", "MQTT password")
host := flag.String("h", "localhost", "MQTT host")
port := flag.Int("p", 1883, "MQTT port")
numberOfClients := flag.Int("n", 1, "Number of concurrent MQTT clients")
idAsSubTopic := flag.Bool("suffix", false, "If set to true integers will be used as sub-topic to the topic specified by 't'. The range goes from 1 to N where N is the max number of configured concurrent clients.")
qos := flag.Int("q", 1, "MQTT QoS used by all clients")
qos := flag.Int("q", 1, "MQTT QoS level used by all clients")
cert := flag.String("cert", "", "Path to TLS certificate file")
ca := flag.String("ca", "", "Path to TLS CA file")
key := flag.String("key", "", "Path to TLS key file")
key := flag.String("key", "", "Path to TLS private key file")
insecure := flag.Bool("insecure", false, "Set to true to allow self signed certificates")
mqtts := flag.Bool("mqtts", false, "Set to true to use MQTTS")
cleanSession := flag.Bool("cleanSession", true, "Set to true for clean MQTT sessions or false to keep session")
clientID := flag.String("clientID", "", "Custom MQTT clientID")
keepAliveTimeout := flag.Int64("keepAliveTimeout", 5000, "Set the amount of time (in seconds) that the client should wait before sending a PING request to the broker")
keepAliveTimeout := flag.Int64("keepAliveTimeout", 5, "Set the amount of time (in seconds) the client should wait for, before sending a PING request to the broker")

flag.Parse()

Expand Down
2 changes: 1 addition & 1 deletion cmd/stdout/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
password := flag.String("P", "", "MQTT password")
host := flag.String("h", "localhost", "MQTT host")
port := flag.Int("p", 1883, "MQTT port")
qos := flag.Int("q", 1, "MQTT QoS used by all clients")
qos := flag.Int("q", 1, "MQTT QoS level used by all clients")

flag.Parse()

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/pablitovicente/mqtt-load-generator
go 1.19

require (
github.com/eclipse/paho.mqtt.golang v1.4.2
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/google/uuid v1.3.0
github.com/paulbellamy/ratecounter v0.2.0
github.com/schollz/progressbar/v3 v3.13.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/eclipse/paho.mqtt.golang v1.4.1 h1:tUSpviiL5G3P9SZZJPC4ZULZJsxQKXxfEN
github.com/eclipse/paho.mqtt.golang v1.4.1/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA=
github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4=
github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA=
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik=
github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
Expand Down

0 comments on commit 7e43d80

Please sign in to comment.