{"id":1319,"date":"2018-07-11T12:36:34","date_gmt":"2018-07-11T11:36:34","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1319"},"modified":"2018-07-11T12:46:47","modified_gmt":"2018-07-11T11:46:47","slug":"mqtt-on-windows","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2018\/mqtt-on-windows","title":{"rendered":"MQTT on Windows"},"content":{"rendered":"<p>I needed to use my Windows 10 Virtual Machine to attend a workshop where labs could only be accessed from Windows operating systems (buh-uh-uh!).<\/p>\n<p>So since I&#8217;m back to Windows again, let&#8217;s see if <del>If<\/del> how I can use MQTT on it.<\/p>\n<p>There are two builds of <a href=\"https:\/\/mosquitto.org\/download\/\">mosquitto<\/a> tools for Windows: one that it&#8217;s based on cygwin and another &#8216;native&#8217; built with Microsoft Visual Studio<\/p>\n<p>I started with the second: <a href=\"http:\/\/www.eclipse.org\/downloads\/download.php?file=\/mosquitto\/binary\/win32\/mosquitto-1.4.15a-install-win32.exe\">mosquitto-1.4.15a-install-win32.exe<\/a><\/p>\n<p>Please note that I&#8217;m using a Windows 10 (x64) virtual machine, not quite full updated and it&#8217;s July 2018&#8230; things might\/will change a bit after a while.<\/p>\n<p>So this is x86 (win32) build but it works on x64. It just needs 3 aditional libraries (dll&#8217;s) to work:<\/p>\n<ul>\n<li>libeay32<\/li>\n<li>ssleay32<\/li>\n<li>pthreadVC2<\/li>\n<\/ul>\n<p>The install wizard says that the first and second library can be extracted from the light install of <a href=\"https:\/\/slproweb.com\/products\/Win32OpenSSL.html\">OpenSSL for Windows<\/a>. But recent versions of OpenSSL no longer use this libraries so I had to download an older one: <a href=\"https:\/\/slproweb.com\/download\/Win32OpenSSL_Light-1_0_2o.exe\">version 1.0.2o<\/a><\/p>\n<p>So I installed this build with the option to include the libraries in the local bin folder where I went to copy &#8220;libeay32.dll&#8221; and &#8220;ssleay32.dll&#8221;. Both libraries properties had &#8220;file version 1.0.2.15, product version 1.0.2o&#8221;.<\/p>\n<p>I copied these 2 files to a new folder &#8220;C:\\mqtt&#8221;<\/p>\n<p>Then I went to <a href=\"https:\/\/sourceforge.net\/projects\/pthreads4w\/\">POSIC Threads for WIndows<\/a> project and downloaded the <a href=\"https:\/\/sourceforge.net\/projects\/pthreads4w\/files\/pthreads-w32-2-9-1-release.zip\/download\">2.9.1<\/a> release and extracted &#8220;Pre-built.2\\dll\\x86\\pthreadVC2.dll&#8221; also to &#8220;C:\\mqtt&#8221;. File properties had &#8220;file version\u00a02.9.0.0, product version\u00a02.9.0.0&#8221;.<\/p>\n<p>Then I installed mosquitto 1.4.15a on the same &#8220;C:\\mqtt&#8221; folder, extracting files and configuring the service. This created a Windows Service named &#8220;Mosquitto Broker&#8221; with a &#8220;MQTT v3.1 broker&#8221; description, configured as &#8220;Automatic&#8221; but not started.<\/p>\n<p>From command line, changing to &#8220;C:\\mqtt&#8221; and executing &#8220;mosquitto_pub.exe&#8221; gives an error stating that another library is missing (MSVCR100.dll). This is from &#8220;Microsoft Visual C++ 2010 Redistributable Package&#8221; so I installed <a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=5555\">the x86 version<\/a>.<\/p>\n<p>Now the same command worked and I could also start the service (&#8220;Mosquitto Broker&#8221;).<\/p>\n<p>The command line argument are the same as for Linux so<\/p>\n<pre>mosquitto_pub.exe -h localhost -m \"0\" -t sfx -r<\/pre>\n<p>works and if I open a second command line window I can see this message arriving:<\/p>\n<pre>mosquitto_sub.exe -h localhost -t sfx<\/pre>\n<p>Nice. Now I can use LEGO MINDSTORMS, Linux, Raspberry Pi, Android, Arduino and Windows systems on my IoT projects. If someone offers me an Apple OSX device, I&#8217;ll be a true polyglIoT ! \ud83d\ude00<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to use my Windows 10 Virtual Machine to attend a workshop where labs could only be accessed from Windows operating systems (buh-uh-uh!). So since I&#8217;m back to Windows again, let&#8217;s see if If how I can use MQTT on it. There are two builds of mosquitto tools for Windows: one that it&#8217;s based &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2018\/mqtt-on-windows\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;MQTT on Windows&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[328,331],"series":[],"class_list":["post-1319","post","type-post","status-publish","format-standard","hentry","category-sem-categoria","tag-iot","tag-mqtt"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-lh","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1319"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1319\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1319"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}