How to test mqtt - cniackz/public GitHub Wiki

  1. Forked and cloned the repo: https://github.com/cniackz/paho.mqtt.golang
  2. Installed mosquitto from https://subscription.packtpub.com/book/application-development/9781787287815/1/ch01lvl1sec12/installing-a-mosquitto-broker-on-macos
  3. Run mosquitto
Cesars-MacBook-Pro:sample cniackz$ mosquitto
1658423212: mosquitto version 2.0.14 starting
1658423212: Using default config.
1658423212: Starting in local only mode. Connections will only be possible from clients running on this machine.
1658423212: Create a configuration file which defines a listener to allow remote access.
1658423212: For more details see https://mosquitto.org/documentation/authentication-methods/
1658423212: Opening ipv4 listen socket on port 1883.
1658423212: Opening ipv6 listen socket on port 1883.
1658423212: mosquitto version 2.0.14 running
  1. Then went to a testing folder in the repo

  2. Send a message to mosquitto:

Cesars-MacBook-Pro:sample cniackz$ go run main.go --action=pub --topic=cesar --message=mind --broker=tcp://localhost:1883 -id=445
Sample Info:
	action:    pub
	broker:    tcp://localhost:1883
	clientid:  445
	user:      
	password:  
	topic:     cesar
	message:   mind
	qos:       0
	cleansess: false
	num:       1
	store:     :memory:
Prior wait command...
Sample Publisher Started
---- doing publish ----
Sample Publisher Disconnected
  1. Received the message:
Cesars-MacBook-Pro:sample cniackz$ go run main.go --action=sub --topic=cesar --broker=tcp://localhost:1883
Sample Info:
	action:    sub
	broker:    tcp://localhost:1883
	clientid:  testgoid
	user:      
	password:  
	topic:     cesar
	message:   
	qos:       0
	cleansess: false
	num:       1
	store:     :memory:
antes de crear al suscriber
1: En un Wait del suscriber
En un Wait del suscriber
En el for del suscriber
RECEIVED TOPIC: cesar MESSAGE: mind
Sample Subscriber Disconnected