I try to connect the NodeMCU with the IBM Bluemix IoT Foundation. The unsecured MQTT connect works splendid and pushes data from a BMP180 to the cloud. However, when I start using TLS it won't connect to the broker. I tried to make a TLS connection with mqtt.fx and it works fine, it seems like the NodeMCU is the problem. If I run this code:
BROKER = orgID..".<bluemix>"
BRPORT = 8883
CLIENTID = "d:"..orgID..":generic_esp:generic_esp_01"
BRPWD = "***********"
BRUSER = "use-token-auth"
local function publish()
function(conn) print('Payload published') end)
m = mqtt.Client(CLIENTID, 120, BRUSER, BRPWD)
c = false
m:on('offline', function(con) print('mqtt offline'); c = false end)
m:connect(BROKER, BRPORT, 1, function(conn)
print('MQTT connected: '..BROKER..':'..BRPORT)
c = true
tmr.alarm(1, 1000, 1, function()
if not c then
c = false
m:connect(BROKER, BRPORT, 1, function(conn) print('.. MQTT reconnected: '..BROKER..':'..BRPORT); c = true end)
if c then
the esp8266 just prints "MQTT reconnecting" and can't connect. Is something wrong with my code or is TLS not fully supported in NodeMCU 1.4, yet?