0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

パブリック MQTT ブローカーの使い方

Last updated at Posted at 2021-01-25

次のブローカーを使ってみました。
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.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?