Unable to connect IBM Bluemix to NodeMCU using TLS Protocol

0 votes

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:

orgID="****"
BROKER = orgID..".<bluemix>"
BRPORT = 8883

CLIENTID = "d:"..orgID..":generic_esp:generic_esp_01"
print("ClientID: "..CLIENTID)
BRPWD  = "***********"

BRUSER = "use-token-auth"

local function publish()
   dofile('sensor.lc')
   m:publish('iot-2/evt/esp8266/fmt/json',payload,1,0, 
            function(conn) print('Payload published') end)
end

m = mqtt.Client(CLIENTID, 120, BRUSER, BRPWD)
c = false

print('MQTT Init')
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 
   publish()
end)

tmr.alarm(1, 1000, 1, function() 
    if not c then
      print('MQTT reconnecting')
      m:close()
      c = false
      m:connect(BROKER, BRPORT, 1, function(conn) print('.. MQTT reconnected: '..BROKER..':'..BRPORT); c = true end)
    end
    if c then
      publish()
    end
 end)

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?

Oct 11, 2018 in IoT (Internet of Things) by Matt
• 2,270 points
857 views

1 answer to this question.

0 votes

I've captured the your client hello in one of our test stands:

0000 16 03 02 00 33 01 00 00 2f 03 02 00 00 00 00 d0 0010 b1 a1 3a 07 1c 1b 3e f2 fc 03 91 d6 18 b5 ae 5d 0020 77 65 37 f5 07 10 45 d1 7e 1a ea 00 00 08 00 2f 0030 00 35 00 05 00 04 01 00

This looks like a TLS v1.1 client hello. Usually a client will hello with the "best" it can do and be negotiated downwards. In this case IoTF will simply close the connection because it only supports TLS 1.2. Please can you check that your device is setup to do TLS 1.2 ?

answered Oct 11, 2018 by anonymous2
• 4,240 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Unable to start Bluemix MobileFirst services starter app

Having used both the Classic UI and ...READ MORE

answered Sep 11, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
504 views
0 votes
1 answer

Connect IBM Watson IoT using Paho MQTT

You should make these changes to the ...READ MORE

answered Oct 10, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,759 views
0 votes
1 answer

Connect Android Things based Raspberry Pi 3 to wifi network for the first time!

Hey, I think its alright!  Your Raspberry Pi ...READ MORE

answered Jul 19, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,158 views
0 votes
1 answer
0 votes
1 answer

Python Code to retrieve data from Device to IBM Bluemix

You connect as a device -> import ibmiotf.device. ...READ MORE

answered Sep 18, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,303 views
0 votes
1 answer

CLI for Watson IBM IoT service in Bluemix

Programmatically register devices using bulk/devices operations. https://docs.internetofthings.ibmcloud.com/swagger/v0002.html#!/Bulk_Operations/post_bulk_devices_add Here's ...READ MORE

answered Nov 23, 2018 in IoT (Internet of Things) by DataKing99
• 8,250 points
823 views
0 votes
1 answer

I cannot retrieve data from historian in Bluemix Watson IoT Platform

You're partially right! Earlier this month, the "built-in" ...READ MORE

answered Jan 11, 2019 in IoT (Internet of Things) by Upasana
• 8,620 points
1,141 views
0 votes
1 answer

Publishing commands to device in IBM IoT using MQTT in Java

If you are publishing from an application, ...READ MORE

answered Jul 27, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,506 views
0 votes
1 answer

Unable to communicate to device with .local domain using android, corova-zeroconf-plugin

Use IP address instead of http://iotdevice.local..Use htt ...READ MORE

answered Aug 2, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,738 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP