8000 allow to specify arbitrary TLS port · Issue #140 · adafruit/Adafruit_CircuitPython_MiniMQTT · GitHub
[go: up one dir, main page]

Skip to content
allow to specify arbitrary TLS port #140
Closed
@vladak

Description

@vladak

As mentioned in #139, some MQTT brokers accept TLS based connections on non-standard port, e.g. test.mosquitto.org:8886.

When I tried something like this:

import adafruit_minimqtt.adafruit_minimqtt as MQTT

...

    broker_port = secrets["broker_port"]  # set to 8886                                      
    MQTT.MQTT_TLS_PORT = broker_port                               
                                                                                
    # Set up a MiniMQTT Client                                                  
    mqtt_client = MQTT.MQTT(                                                    
        broker=secrets["broker"],                                               
        port=broker_port,                                                       
        socket_pool=pool,                                                       
        ssl_context=ssl_context,                                                
    )

    mqtt_client.connect()

it failed (with the changes for the above mentioned PR in place), because it tried to initiate 'INSECURE' (quoting the log message) connection.

Clearly something better than overriding global variable is needed, perhaps a new attribute with a setter. Or maybe my Python-fu is not enough and some other incantation is needed to overwrite the TLS port definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0