{"id":2019,"date":"2017-03-23T22:31:07","date_gmt":"2017-03-23T22:31:07","guid":{"rendered":"http:\/\/justthesam.com\/?p=2019"},"modified":"2017-03-23T22:31:07","modified_gmt":"2017-03-23T22:31:07","slug":"building-and-running-vernemq-on-macos","status":"publish","type":"post","link":"https:\/\/justthesam.com\/?p=2019","title":{"rendered":"Building and running VerneMQ on macOS"},"content":{"rendered":"<p>I&#8217;ve been looking at several\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/MQTT\">MQTT<\/a> brokers recently, and whilst I shan&#8217;t go into all the details of that, I shall post my hard-earned learnings on how to get <a href=\"https:\/\/vernemq.com\">VerneMQ<\/a> built and running on macOS 10.12. This is all cobbled together from Googling various issues I ran into and bludgeoning my way to success, but hopefully this end to end description will be useful to somebody. To be honest, I have been massively put off VerneMQ because of this\u00a0poor out-of-box developer experience and the extremely limited\u00a0documentation.<\/p>\n<h2>Building<\/h2>\n<ul>\n<li>Ensure XCode and its command line tools are installed, because we&#8217;ll need the command line compiler tools.<\/li>\n<li>VerneMQ is built on Erlang, so we need to install that. Unfortunately the official &#8220;Erlang Installer&#8221; for mac didn&#8217;t work, giving an error: &#8220;erl could not be removed&#8221;. Thankfully brew works nicely. Don&#8217;t know why I didn&#8217;t try that straight off.\n<ul>\n<li>If you haven&#8217;t already got brew, install it from\u00a0<a href=\"https:\/\/brew.sh\">https:\/\/brew.sh<\/a>. It&#8217;s really very quick and simple and a must-have tool anyway. Then install Erlang:\n<pre>&gt; brew install erlang<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Get the VerneMQ code:\n<pre>&gt; git clone git:\/\/github.com\/erlio\/vernemq.git vernemq_git\n&gt; cd vernemq_git<\/pre>\n<\/li>\n<li>The build would\u00a0fail with &#8220;vmq_passwd.c:32:10: fatal error: &#8216;openssl\/evp.h&#8217; file not found&#8221;, on macOS 10.11+, so we need to specify openssl location in CFLAGS. Ensure openssl is installed first if necessary, with brew:\n<pre>&gt; brew install openssl<\/pre>\n<\/li>\n<li>Get past an erlang rebar bug, caused by files being readonly, by <a href=\"https:\/\/github.com\/esl\/MongooseIM\/issues\/1170#issuecomment-276077425\">making them readable<\/a> (bit of a hacky workaround):\n<pre>&gt; chmod -R u+w \/usr\/local\/Cellar\/erlang<\/pre>\n<\/li>\n<li>Actually build it, now we have everything we need, adapting the path here as necessary to match the openssl version you actually have.\n<pre>&gt; CFLAGS=\"-I \/usr\/local\/Cellar\/openssl\/1.0.2k\/include -L\/usr\/local\/Cellar\/openssl\/1.0.2k\/lib\" make rel<\/pre>\n<\/li>\n<li>If that succeeded (after a fair while) you should have the binaries in\u00a0_build\/default\/rel\/vernemq\/bin\/<\/li>\n<\/ul>\n<h2>Running<\/h2>\n<p>It&#8217;s trivial to start the binary with default config:<\/p>\n<pre>_build\/default\/rel\/vernemq\/bin\/vernemq start<\/pre>\n<p>Note that this starts it up then quits, but leaves the server running. You can do the same but with &#8216;stop&#8217; to shut it down.\u00a0See <a href=\"https:\/\/vernemq.com\/docs\/getting-started\/\">the docs<\/a> on further things you can do with the vernemq binary.<\/p>\n<h2>Configuration<\/h2>\n<p>If you&#8217;ve just built it and are running from the _build location, the config file it is using is at _build\/default\/rel\/vernemq\/etc\/vernemq.conf<\/p>\n<p>I turned on anonymous users and added a websockets listener by following the instructions in that file. I restarted the server (vernemq restart) and then was able to successfully publish and subscribe with the handy <a href=\"http:\/\/www.hivemq.com\/demos\/websocket-client\/\">HiveMQ online WebSocket MQTT client<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been looking at several\u00a0MQTT brokers recently, and whilst I shan&#8217;t go into all the details of that, I shall post my hard-earned learnings on how to get VerneMQ built and running on macOS 10.12. This is all cobbled together from Googling various issues I ran into and bludgeoning my way to success, but hopefully [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,33],"tags":[],"class_list":["post-2019","post","type-post","status-publish","format-standard","hentry","category-programming","category-webtech"],"_links":{"self":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/2019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2019"}],"version-history":[{"count":0,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/2019\/revisions"}],"wp:attachment":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}