次のブローカーを使ってみました。
Free Public MQTT 5 Broker Server
MQTT
publish
go_pub_mqtt.sh
message="Hello Mqtt "`date`
mosquitto_pub -d -t orz -m "${message}" \
-h broker.emqx.io \
--topic example/testTopic
subscribe
go_sub_mqtt.sh
mosquitto_sub -d -t orz -h broker.emqx.io \
--topic example/testTopic
実行結果
$ mosquitto_sub -d -t orz -h broker.emqx.io --topic example/testTopic
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: orz, QoS: 0, Options: 0x00)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: example/testTopic, QoS: 0, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 0, 0
Client (null) received PUBLISH (d0, q0, r0, m0, 'example/testTopic', ... (53 bytes))
Hello Mqtt 2021年 8月 10日 火曜日 18:39:44 JST
Client (null) sending PINGREQ
Client (null) received PINGRESP
Client (null) received PUBLISH (d0, q0, r0, m0, 'example/testTopic', ... (53 bytes))
Hello Mqtt 2021年 8月 10日 火曜日 18:40:12 JST
MQTTS
publish
go_pub_mqtts.sh
message="Hello Mqtt "`date`
mosquitto_pub -d -t orz -m "${message}" \
-h broker.emqx.io \
-p 8883 --capath /etc/ssl/certs/ \
--topic example/testTopic
subscribe
go_sub_mqtts.sh
mosquitto_sub -d -t orz -h broker.emqx.io \
-p 8883 --capath /etc/ssl/certs/ \
--topic example/testTopic
確認したバージョン
$ mosquitto_pub --version
mosquitto_pub version 2.0.18 running on libmosquitto 2.0.18.
$ mosquitto_sub --version
mosquitto_sub version 2.0.18 running on libmosquitto 2.0.18.