<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Crash with MQTT]]></title><description><![CDATA[<p dir="auto">I have been using MQTT properly with the following code for a long time, and then yesterday I noticed my buttons weren't responding and when checking the Flic Hub Studio console I see that my script is crashing over and over again when running <code>mqttClient.connect()</code> with the following error:</p>
<pre><code>TypeError: Invalid type
    at invoke (native)
    at connectWithHostAndPort (core.js:1273)
    at &lt;anonymous&gt; (core.js:1332)
    at func (core.js:2325)
    at nextTickHandler (core.js:2334)
</code></pre>
<p dir="auto">Here is my whole MQTT code, and I am using the latest version of <code>mqtt.js</code> that is posted on <a href="https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js" rel="nofollow ugc">https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js</a></p>
<pre><code>const mqttClient = require('./mqtt').create(mqttBroker, {username: mqttUsername, password: mqttPassword}) // https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js

mqttClient.on('connected', () =&gt; {
	console.log(`Connected to MQTT Broker ${mqttBroker}`)
	mqttClient.subscribe('[TOPIC]')
})

mqttClient.on('disconnected', () =&gt; {
	throw new Error(`DISCONNECTED from MQTT Broker ${mqttBroker}`) // Error to restart script if disconnected from MQTT broker.
})

mqttClient.on('publish', (pub) =&gt; {
	console.log(`\nReceived MQTT Message on Topic: ${pub.topic}\n${pub.message}`)

	// Handle button actions here.
})

mqttClient.connect()
setInterval(() =&gt; { if (!mqttClient.connected) throw new Error('MQTT Broker NOT CONNECTED') }, 900000)
// Check every 15 minutes that MQTT Broker is connected, and throw error to restart script if not.
// This check is important if fails to connect to MQTT Broker at launch, when the "disconnected" event would never be sent.
</code></pre>
]]></description><link>https://community.flic.io/topic/18578/crash-with-mqtt</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 19:58:35 GMT</lastBuildDate><atom:link href="https://community.flic.io/topic/18578.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 Sep 2025 17:54:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Crash with MQTT on Fri, 19 Sep 2025 18:39:49 GMT]]></title><description><![CDATA[<p dir="auto">I just noticed this post <a href="https://community.flic.io/topic/18577/mqtt-issue-on-firmware-version-4-4-5">https://community.flic.io/topic/18577/mqtt-issue-on-firmware-version-4-4-5</a> and updated Flic Hub to version 4.4.6 which appears to have solved the crash.</p>
]]></description><link>https://community.flic.io/post/21990</link><guid isPermaLink="true">https://community.flic.io/post/21990</guid><dc:creator><![CDATA[pico]]></dc:creator><pubDate>Fri, 19 Sep 2025 18:39:49 GMT</pubDate></item></channel></rss>