2

I have the following micro python code:

client = MQTTClient("youraccount/feeds/lights", "a21sigud7911d7.iot.us-west- 
2.amazonaws.com", user="None", password="None" , keepalive=10000, ssl=True, 
ssl_params={"certfile":"/49c84a8c4a-certificate.pem.crt", 
"keyfile":"/49c84a8c4a-private.pem.key", "ca_certs":"/root.pem"})


 client.settimeout = settimeout
 client.connect()

But when I run the script from repl on ESP32 i get:

File "umqtt/simple.py", line 61, in connect TypeError: extra keyword arguments given

Any help please

user3570022
  • 85
  • 1
  • 11

2 Answers2

2

Remove the ca_certs in the ssl_params dictionary. Refer to Micropython connecting to AWS with MQTT and the warning in ussl documentation.
Connecting to AWS using the ESP32 and the Micropython-lib MQTT is possible on the ESP32 because it used mbedtls. However, it is not possible on unix/osx because it uses the axtls library - refer to this issue.

TomManning
  • 101
  • 4
1

I wasn't trying to connect to AWS (but rather my own TLS secured MQTT Broker) – and I had exactly the same error message. In case anyone else finds this, when trying to solve that problem – the answer is actually really easy. You can't use the names of the files – but rather need their contents. So this worked for me:

    from umqtt.robust import MQTTClient

    with open('device.key') as f:
        key_data = f.read()
    with open('device.crt') as f:
        cert_data = f.read()

    client = MQTTClient("ESP", "test.example.com", ssl=True, ssl_params={'key':key_data, 'cert':cert_data})
    x = client.connect()
    if not x:
        client.publish("Topic", "Hello World...")

You'll obviously need to replace "test.example.com" with the URL for your secure MQTT server...

AJ Poulter
  • 1,717
  • 2
  • 10
  • 9