Working clients

drew/mqtt-clients
Drew Bednar 4 months ago
parent cf0a8d3049
commit 519d5f2a95

@ -23,7 +23,7 @@
allow_anonymous false
# allow_zero_length_clientid
# auto_id_prefix
# password_file
password_file /etc/mosquitto/passwd
# plugin
# plugin_opt_*
# psk_file

@ -28,4 +28,8 @@ run-pub:
run-sub:
go run ./cmd/subscriber/main.go
.PHONEY: run-sub
.PHONEY: run-sub
dev-logs:
docker logs mosquitto -f
.PHONEY: dev-logs

@ -15,7 +15,7 @@ func main() {
options := mqtt.NewClientOptions()
options.AddBroker(fmt.Sprintf("tcp://%s:%s", *common.BrokerHost, *common.BrokerPort))
// options.SetClientID("go_mqtt_client")
options.SetClientID("go_mqtt_pub_client")
options.SetUsername("dirp")
options.SetPassword("dirp")
options.SetDefaultPublishHandler(func(client mqtt.Client, msg mqtt.Message) {

@ -37,7 +37,7 @@ func main() {
var port = 1883
opts := mqtt.NewClientOptions()
opts.AddBroker(fmt.Sprintf("tcp://%s:%d", broker, port))
// opts.SetClientID("go_mqtt_client")
opts.SetClientID("go_mqtt_sub_client")
opts.SetUsername("dirp")
opts.SetPassword("dirp")
opts.SetDefaultPublishHandler(messagePubHandler)

Loading…
Cancel
Save