Arch Linux でテストしました。
参考ページ
MQTT: localhost でのテスト
mosquitto の設定変更
/etc/mosquitto/mosquitto.conf
listener 8083
allow_anonymous true
listener 8080
protocol websockets
再起動
sudo systemctl restart mosquitto
Publish
BROKER="localhost"
#
echo $BROKER
message="Hello Mqtt "`date`
mosquitto_pub -d -t orz -m "${message}" \
-h $BROKER \
--topic example/testTopic -p 8083
Subscribe
BROKER="localhost"
#
mosquitto_sub -d -t orz -h $BROKER \
--topic example/testTopic -p 8083
mqtt コマンドライン を使って接続
Publish
mqtt pub -t 'example/testTopic' -h 'localhost' -p 8083 -m 'Good Afternoon'
Subscribe
mqtt sub -t 'example/testTopic' -h 'localhost' -p 8083 -v