inovex / mqtt-stresser

Load testing tool to stress MQTT message broker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: close of nil channel

ethsonliu opened this issue · comments

When run the exe with ./mqtt-stresser-linux-amd64-static -broker tcp://45.76.163.6:1883 -num-clients 32219 -num-messages 100 -publisher-qos 2 -subscriber-qos 2 at the platform of Ubuntu 14.04 x64.

(45.76.163.6 is my centos6 1G 1CPU vps in vultr.com in Singapore, if you want, you can use it to test, and it's broker's web service port is 18083)

Here is the output,

100 worker started - waiting 500ms
200 worker started - waiting 500ms
300 worker started - waiting 500ms
400 worker started - waiting 500ms
500 worker started - waiting 500ms
600 worker started - waiting 500ms
700 worker started - waiting 500ms
800 worker started - waiting 500ms
900 worker started - waiting 500ms
1000 worker started - waiting 500ms
1100 worker started - waiting 500ms
1200 worker started - waiting 500ms
1300 worker started - waiting 500ms
1400 worker started - waiting 500ms
1500 worker started - waiting 500ms
1600 worker started - waiting 500ms
1700 worker started - waiting 500ms
1800 worker started - waiting 500ms
1900 worker started - waiting 500ms
2000 worker started - waiting 500ms
2100 worker started - waiting 500ms
2200 worker started - waiting 500ms
2300 worker started - waiting 500ms
2400 worker started - waiting 500ms
2500 worker started - waiting 500ms
2600 worker started - waiting 500ms
2700 worker started - waiting 500ms
2800 worker started - waiting 500ms
2900 worker started - waiting 500ms
3000 worker started - waiting 500ms
3100 worker started - waiting 500ms
3200 worker started - waiting 500ms
3300 worker started - waiting 500ms
3400 worker started - waiting 500ms
3500 worker started - waiting 500ms
3600 worker started - waiting 500ms
3700 worker started - waiting 500ms
3800 worker started - waiting 500ms
3900 worker started - waiting 500ms
4000 worker started - waiting 500ms
4100 worker started - waiting 500ms
4200 worker started - waiting 500ms
4300 worker started - waiting 500ms
4400 worker started - waiting 500ms
4500 worker started - waiting 500ms
4600 worker started - waiting 500ms
4700 worker started - waiting 500ms
4800 worker started - waiting 500ms
4900 worker started - waiting 500ms
5000 worker started - waiting 500ms
5100 worker started - waiting 500ms
5200 worker started - waiting 500ms
5300 worker started - waiting 500ms
5400 worker started - waiting 500ms
5500 worker started - waiting 500ms
5600 worker started - waiting 500ms
5700 worker started - waiting 500ms
5800 worker started - waiting 500ms
5900 worker started - waiting 500ms
6000 worker started - waiting 500ms
6100 worker started - waiting 500ms
panic: close of nil channel

goroutine 31121 [running]:
github.com/inovex/mqtt-stresser/vendor/github.com/eclipse/paho%2emqtt%2egolang.(*client).closeStop(0xc01de78380)
	/Users/ab/Documents/dev/GOPATH/src/github.com/inovex/mqtt-stresser/vendor/github.com/eclipse/paho.mqtt.golang/client.go:482 +0x12f
github.com/inovex/mqtt-stresser/vendor/github.com/eclipse/paho%2emqtt%2egolang.(*client).disconnect(0xc01de78380)
	/Users/ab/Documents/dev/GOPATH/src/github.com/inovex/mqtt-stresser/vendor/github.com/eclipse/paho.mqtt.golang/client.go:495 +0x2f
github.com/inovex/mqtt-stresser/vendor/github.com/eclipse/paho%2emqtt%2egolang.(*client).Disconnect(0xc01de78380, 0x5)
	/Users/ab/Documents/dev/GOPATH/src/github.com/inovex/mqtt-stresser/vendor/github.com/eclipse/paho.mqtt.golang/client.go:439 +0x1f9
main.(*Worker).Run(0xc01dd71140, 0x719f40, 0xc000054420)
	/Users/ab/Documents/dev/GOPATH/src/github.com/inovex/mqtt-stresser/worker.go:127 +0xf23
created by main.main
	/Users/ab/Documents/dev/GOPATH/src/github.com/inovex/mqtt-stresser/main.go:174 +0x592

Can you retest with #27 ? I think that is an issue in the mqtt library. I updated to the latest version of that library. That should fix your problem.

Hi, I rebuild the project, but something went wrong.

jalyn@Ubuntu-64:~/mqtt-stresser-upgrade-mqtt-library$ make linux
GO111MODULE=on GOOS=linux GOARCH=amd64 go build -mod=vendor -o build/mqtt-stresser-linux-amd64
flag provided but not defined: -mod
usage: build [-o output] [build flags] [packages]

Build compiles the packages named by the import paths,
along with their dependencies, but it does not install the results.

If the arguments are a list of .go files, build treats them as a list
of source files specifying a single package.

When the command line specifies a single main package,
build writes the resulting executable to output.
Otherwise build compiles the packages but discards the results,
serving only as a check that the packages can be built.

The -o flag specifies the output file name. If not specified, the
output file name depends on the arguments and derives from the name
of the package, such as p.a for package p, unless p is 'main'. If
the package is main and file names are provided, the file name
derives from the first file name mentioned, such as f1 for 'go build
f1.go f2.go'; with no files provided ('go build'), the output file
name is the base name of the containing directory.

The build flags are shared by the build, install, run, and test commands:

	-a
		force rebuilding of packages that are already up-to-date.
	-n
		print the commands but do not run them.
	-p n
		the number of builds that can be run in parallel.
		The default is the number of CPUs available.
	-race
		enable data race detection.
		Supported only on linux/amd64, darwin/amd64 and windows/amd64.
	-v
		print the names of packages as they are compiled.
	-work
		print the name of the temporary work directory and
		do not delete it when exiting.
	-x
		print the commands.

	-ccflags 'arg list'
		arguments to pass on each 5c, 6c, or 8c compiler invocation.
	-compiler name
		name of compiler to use, as in runtime.Compiler (gccgo or gc).
	-gccgoflags 'arg list'
		arguments to pass on each gccgo compiler/linker invocation.
	-gcflags 'arg list'
		arguments to pass on each 5g, 6g, or 8g compiler invocation.
	-installsuffix suffix
		a suffix to use in the name of the package installation directory,
		in order to keep output separate from default builds.
		If using the -race flag, the install suffix is automatically set to race
		or, if set explicitly, has _race appended to it.
	-ldflags 'flag list'
		arguments to pass on each 5l, 6l, or 8l linker invocation.
	-tags 'tag list'
		a list of build tags to consider satisfied during the build.
		See the documentation for the go/build package for
		more information about build tags.

The list flags accept a space-separated list of strings. To embed spaces
in an element in the list, surround it with either single or double quotes.

For more about specifying packages, see 'go help packages'.
For more about where packages and binaries are installed,
run 'go help gopath'.  For more about calling between Go and C/C++,
run 'go help c'.

See also: go install, go get, go clean.
make: *** [build/mqtt-stresser-linux-amd64] 错误 2

Linux platform is Ubuntu 14.04, and my go version and env are,

jalyn@Ubuntu-64:~/mqtt-stresser-upgrade-mqtt-library$ go version
go version go1.2.1 linux/amd64
jalyn@Ubuntu-64:~/mqtt-stresser-upgrade-mqtt-library$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"

We moved to go modules in that branch. This requires at least go 1.11. I recommend 1.12.

You could try to remove the -mod=vendor in the Makefile. (

build = GO111MODULE=on GOOS=$(1) GOARCH=$(2) go build -mod=vendor -o build/$(appname)-$(1)-$(2)$(3)
and
static-build = GO111MODULE=on CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) GOARM=$(4) go build -mod=vendor -a -installsuffix cgo -o build/$(appname)-$(1)-$(2)$(4)-static$(3) .
)

I changed go to 1.12, and remove -mod=vendor, but,

jalyn@Ubuntu-64:~/mqtt-stresser-upgrade-mqtt-library$ go version
go version go1.12.2 linux/amd64
jalyn@Ubuntu-64:~/mqtt-stresser-upgrade-mqtt-library$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jalyn/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jalyn/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build345339705=/tmp/go-build -gno-record-gcc-switches"
jalyn@Ubuntu-64:~/mqtt-stresser-upgrade-mqtt-library$ make linux
go mod init
go: cannot determine module path for source directory /home/jalyn/mqtt-stresser-upgrade-mqtt-library (outside GOPATH, no import comments)
make: *** [go.mod] 错误 1

If you moved to go 1.12, you don't have to remove -mod=vendor.
Furthermore, the go mod init is odd. Did you remove the go.mod file? the go mod init only happens if that file is not present.

Yes, you are right. Build successfully.