nodemcu-firmware: Secure MQTT does not try connecting at all

Expected behavior

MQTT Client connect(“broker”, 8883, 1) should connect to the broker

Actual behavior

It doesn’t even try to initiate the connection and just fails with reason = -5 (mqtt.CONN_FAIL_SERVER_NOT_FOUND)

Test code

--  mqtt_client:connect("broker", 1883, 0, function(client)
    mqtt_client:connect("broker", 8883, 1, function(client)
        print("MQTT connected")
    end, function(client, reason)
        print("MQTT connect failed: " .. reason)
    end)

By uncommenting the line with port 1883 and commenting out the other secure connection line I can get immediate connection to broker so DNS, path to broker and broker itself work OK.

Broker

I use Mosquitto carefully configured to use tlsv1.1 to please NodeMCU that is limited to TLS v1.1 only (master branch, at least). The certificate on broker is from Let’s Encrypt but I didn’t load them to NodeMCU. Instead, I relied on the net.cert.verify(false)

EDIT: actually I also tried loading the certificate to tls.cert.verify(), but it didn’t help.

TCPDump

I ran tcpdump at the broker to see if NodeMCU tries to connect at all. I can confirm that there was no attempt - zero bytes transferred, the connection wasn’t even initiated. Another test client (an Android app named MQTT Dash) connected to broker just fine so the port is open, broker is listening there and no firewall issues are in the way.

NodeMCU version

Tried both current master and dev (61d20a75e24ff0bd5c90acf2b207847c7cea9970), same behavior.

Hardware

Wemos Mini

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 30 (19 by maintainers)

Most upvoted comments

1.5.4.1-final does not use mbedTLS but axTLS which is limited to TLS 1.1: https://nodemcu.readthedocs.io/en/1.5.4.1-final/en/modules/net/