1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[MQTT] mqttcliをインストールしてsangoにつないでみる

Last updated at Posted at 2015-04-03

mqttcliをインストールしてsangoにつないでみます。

参考: http://tdoc.info/blog/2014/09/10/micorservice.html

前提条件

sango

sangoのアカウントを持っていて、トピックを利用できること。

  1. ダウンロード
    ===============

https://drone.io/github.com/shirou/mqttcli/files からバイナリをダウンロードします。

  • OSXの場合はDarwin用をダウンロードします。
  1. インストール
    ===============

2.1. インストール

ここでは、~/binに配備します。

コマンド(例)
mv ~/Downloads/mqttcli ~/bin/
chmod +x ~/bin/mqttcli

2.2. バージョン確認

インストールしたらバージョンを確認しましょう。

コマンド
~/bin/mqttcli -v
結果(例)
mqttcli version 0.0.1
  1. 設定ファイルの作成
    =====================

3.1. 接続情報の確認

ダッシュボードの「MQTT接続情報」を基に以下を設定します。

例:
:接続先: tcp://lite.mqtt.shiguredo.jp:1883
:ユーザー名: example@github
:パスワード: your_secret

コマンド(例)
SANGO_URL='lite.mqtt.shiguredo.jp'
SANGO_ID='<ユーザ名>'
SANGO_PW='<パスワード>'
FILE_SANGO_CONF="${HOME}/.mqttcli.cfg"

3.2. 設定ファイルの作成

設定ファイル ~/.mqttcliを作成します。

コマンド
cat << EOF > ${FILE_SANGO_CONF}
{
    "host": "${SANGO_URL}",
    "username": "${SANGO_ID}",
    "password": "${SANGO_PW}"
}
EOF

cat ${FILE_SANGO_CONF}
  1. 接続テスト
    =====================

インストールと設定ファイルの作成が完了したので、sangoに接続してみましょう。

コマンド(例)
~/bin/mqttcli sub -t "${SANGO_ID}/#" -d
結果
      INFO[0000] Broker URI: tcp://lite.mqtt.shiguredo.jp:1883
      INFO[0000] Topic: example@github/#
      INFO[0000] connecting...
      INFO[0000] client connected

上記が確認できたら、Ctrl+Cで接続を切断します。

完了

インストールが完了したら、MicroServiceっぽいことをやってみましょう。

[MQTT] mqttcliとsangoでMicroServiceっぽいことをやってみる: http://qiita.com/tcsh/items/76213e58ad557a57e057

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?