inovex / mqtt-stresser

Load testing tool to stress MQTT message broker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No connection to localhost broker

AlmostRuio opened this issue · comments

Hello,
i tried many times to connect to a local broker (127.0.0.1) (docker image eclipse-mosquitto) without success (mqtt-stresser container).
With another broker in my local network (ip adress) it's working flawlessly.
I tried to debug without success.

Here some tries (i verified with mosquitto_pub that the broker is up)

~/bin/apache-jmeter-5.4/bin $ docker run inovex/mqtt-stresser -broker :1883 -num-clients 1 -num-messages 10 -log-level 2
1 worker started
DEBUG: 11:47:58.796291 worker.go:89: [0] initializing
DEBUG: 11:47:58.796361 worker.go:104: [0] topic=internal/mqtt-stresser/de1628ebb3d9/worker0-2132015686 subscriberClientId=mqtt-stresser-sub-de1628ebb3d9-worker0-2132015686 publisherClientId=mqtt-stresser-pub-de1628ebb3d9-worker0-2132015686
DEBUG: 11:47:58.796384 worker.go:133: [0] connecting subscriber
DEBUG: 11:48:03.796613 worker.go:155: [0] subscribing to topic
DEBUG: 11:48:03.796696 worker.go:146: [0] unsubscribe
DEBUG: 11:48:03.796758 main.go:291: 1/1 events received
failed to unsubscribe: Not Connected
~/bin/apache-jmeter-5.4/bin $ docker run inovex/mqtt-stresser -broker localhost:1883 -num-clients 1 -num-messages 10 -log-level 2
1 worker started
DEBUG: 11:48:47.676236 worker.go:89: [0] initializing
DEBUG: 11:48:47.676318 worker.go:104: [0] topic=internal/mqtt-stresser/9038eac90665/worker0-1771842039 subscriberClientId=mqtt-stresser-sub-9038eac90665-worker0-1771842039 publisherClientId=mqtt-stresser-pub-9038eac90665-worker0-1771842039
DEBUG: 11:48:47.676346 worker.go:133: [0] connecting subscriber
failed to unsubscribe: Not Connected
DEBUG: 11:48:52.676640 worker.go:155: [0] subscribing to topic
DEBUG: 11:48:52.676783 worker.go:146: [0] unsubscribe
DEBUG: 11:48:52.676858 main.go:291: 1/1 events received
~/bin/apache-jmeter-5.4/bin $ docker run inovex/mqtt-stresser -broker 127.0.0.1:1883 -num-clients 1 -num-messages 10 -log-level 2
1 worker started
DEBUG: 11:49:25.085916 worker.go:89: [0] initializing
DEBUG: 11:49:25.086003 worker.go:104: [0] topic=internal/mqtt-stresser/dd21babcd6b3/worker0-1451970135 subscriberClientId=mqtt-stresser-sub-dd21babcd6b3-worker0-1451970135 publisherClientId=mqtt-stresser-pub-dd21babcd6b3-worker0-1451970135
DEBUG: 11:49:25.086023 worker.go:133: [0] connecting subscriber
EDEBUG: 11:49:30.086227 worker.go:155: [0] subscribing to topic
DEBUG: 11:49:30.086319 main.go:291: 1/1 events received
DEBUG: 11:49:30.086382 worker.go:146: [0] unsubscribe

Working with mosquitto_pub:

~/bin/apache-jmeter-5.4/bin $ mosquitto_pub -m "{\"status\":\"off\"}" -t "test/topic" --repeat 1000 --repeat-delay 2 -p 1883 -d
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending PUBLISH (d0, q0, r0, m1, 'test/topic', ... (16 bytes))
Client (null) sending PUBLISH (d0, q0, r0, m2, 'test/topic', ... (16 bytes))
Client (null) sending PUBLISH (d0, q0, r0, m3, 'test/topic', ... (16 bytes))

Sorry if I forgot something.

Thank you,
ruio

Ps: i tried to run the binaries without success

~/Downloads $ ./mqtt-stresser-linux-amd64 -broker :1883 -num-clients 1 -num-messages 10 -log-level 2
open : no such file or directory

Ps2: I tried to make without success

~/workspace/mqtt-stresser (master)$ make
GO111MODULE=on GOOS=windows GOARCH=amd64 go build -mod=vendor -o build/mqtt-stresser-windows-amd64.exe
flag provided but not defined: -mod
usage: build [-o output] [-i] [build flags] [packages]
Run 'go help build' for details.
Makefile:81: recipe for target 'build/mqtt-stresser-windows-amd64.exe' failed
make: *** [build/mqtt-stresser-windows-amd64.exe] Error 2

Hi!

You didn't show how you expose your broker. I believe containers don't see each other as long as their not in the same network (e.g. bridge). If your broker is running in a container, put both of them into the same network or expose broker/container port on a host port using -p. This should be done on an IP address the mqtt-stresser can actually reach.

Compiling still works on my mac.

┌──[ ab - [~/dev/GOPATH/src/github.com/inovex/mqtt-stresser] - [00h 00m 00s] - master
└──[ make clean all
rm -rf build/
GO111MODULE=on GOOS=windows GOARCH=amd64 go build -mod=vendor -o build/mqtt-stresser-windows-amd64.exe
GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -mod=vendor -o build/mqtt-stresser-darwin-amd64
GO111MODULE=on GOOS=linux GOARCH=amd64 go build -mod=vendor -o build/mqtt-stresser-linux-amd64
GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=amd64 GOARM= go build -mod=vendor -a -installsuffix cgo -o build/mqtt-stresser-windows-amd64-static .
GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 GOARM= go build -mod=vendor -a -installsuffix cgo -o build/mqtt-stresser-darwin-amd64-static .
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARM= go build -mod=vendor -a -installsuffix cgo -o build/mqtt-stresser-linux-amd64-static .
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -mod=vendor -a -installsuffix cgo -o build/mqtt-stresser-linux-arm5-static .
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -mod=vendor -a -installsuffix cgo -o build/mqtt-stresser-linux-arm6-static .
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -mod=vendor -a -installsuffix cgo -o build/mqtt-stresser-linux-arm7-static .

┌──[ ab - [~/dev/GOPATH/src/github.com/inovex/mqtt-stresser] - [00h 00m 34s] - master
└──[ sw_vers
ProductName:	macOS
ProductVersion:	11.0.1
BuildVersion:	20B50

┌──[ ab - [~/dev/GOPATH/src/github.com/inovex/mqtt-stresser] - [00h 00m 00s] - master
└──[ go version
go version go1.15.2 darwin/amd64

Please also have a look at the example in the README file and use a fully qualified URI like tcp://broker.mqttdashboard.com:1883.

Hi @arnisoph ,

Thank you, you're right about docker containers network.
I resolved by building (go was outdated) and now i reach the broker image.

Thank you again and have a nice one,
ruio

Awesome! Have a great time. 👋