Help us understand the problem. What is going on with this article?

Mosquitto - Brew パッケージの不具合

概要

mosquittoのbrewパッケージにバグがあります

この投稿の読者

  • OSXでmosquittoを動かす方
  • brewでmosquittoをインストールした方
  • mosquittoをシステムサービスと稼働したい方
  • Subscriber/Publisherからconnection refusedと怒られてしまい困っている方

結論(対策)

mosquittoインストール後、次の様にディレクトリを作成してください

$ sudo mkdir /usr/local/var/mosquitto
$ sudo chmod 775 /usr/local/var/mosquitto

現象

(1) コマンドラインから指定すれば動作

これなら動きます

$ /usr/local/sbin/mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf
 1571663276: mosquitto version 1.6.7 starting
 1571663276: Config loaded from /usr/local/etc/mosquitto/mosquitto.conf.
 1571663276: Opening ipv6 listen socket on port 1883.
 1571663276: Opening ipv4 listen socket on port 1883.
...
$ mosquitto_sub -d -t orz
 Client mosq-PteU0oBSzkCWYl8edo sending CONNECT
 Client mosq-PteU0oBSzkCWYl8edo received CONNACK (0)
 Client mosq-PteU0oBSzkCWYl8edo sending SUBSCRIBE (Mid: 1, Topic: orz, QoS: 0, Options: 0x00)
 Client mosq-PteU0oBSzkCWYl8edo received SUBACK

(2) サービスとしては起動失敗

下記の様にサービスとしてmosquittoを起動すると失敗。subscriber等からアクセスできません。

$ brew services start mosquitto
 ==> Successfully started `mosquitto` (label: homebrew.mxcl.mosquitto)
...
$ mosquitto_sub -d -t orz
 Error: Connection refused
...


# launchctlでも同じ
$ launchctl load /usr/local/Cellar/mosquitto/1.6.7/homebrew.mxcl.mosquitto.plist
...
$ mosquitto_sub -d -t orz
 Error: Connection refused
...

バグ

(1)原因

plistファイルで指定されるWorkingDirectoryが存在しないため

(2)解説

  • サービスとして動作を記述するplistファイルで指定される実行ディレクトが存在しない。
  • サービス起動時にエラーも吐かず「成功メッセージ」がでます。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.mosquitto</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/mosquitto/sbin/mosquitto</string>
    <string>-c</string>
    <string>/usr/local/etc/mosquitto/mosquitto.conf</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <false/>
  <key>WorkingDirectory</key>
  <string>/usr/local/var/mosquitto</string>    <===== ココ
</dict>
</plist>

(3)対応

上記の「結論(対策)」を実行してください

$ sudo mkdir /usr/local/var/mosquitto
$ sudo chmod 775 /usr/local/var/mosquitto

感想

パッケージャのミスで、早々に治るかと思いましたが、思いの外情報がなく、
brewに投稿するより、こちらの方が苦しむ方が減るかと思い。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした