Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after updating to 5.0.4 - Feathers2 #73

Closed
ghayne opened this issue Mar 5, 2021 · 14 comments
Closed

Error after updating to 5.0.4 - Feathers2 #73

ghayne opened this issue Mar 5, 2021 · 14 comments

Comments

@ghayne
Copy link

ghayne commented Mar 5, 2021

After updating to 5.0.4 on my Feathers2 I am getting the following error, the code was working on 5.0.0.

Traceback (most recent call last):
File "", line 1, in
File "codeold.py", line 86, in
File "adafruit_minimqtt/adafruit_minimqtt.py", line 437, in connect
File "adafruit_minimqtt/adafruit_minimqtt.py", line 235, in _get_connect_socket
AttributeError: 'NoneType' object has no attribute 'info'

@ghayne ghayne changed the title Errors after updating to 5.0.4 - Feathers2 Error after updating to 5.0.4 - Feathers2 Mar 5, 2021
@brentru
Copy link
Member

brentru commented Mar 5, 2021

@ghayne What version of CircuitPython are you running on the FeatherS2?

What does your codeold.py look like (what function call is it failing on?)

@ghayne
Copy link
Author

ghayne commented Mar 5, 2021

@brentru CircuitPython 6.2.0-beta.3 - I tried -beta-2 too.

It,s failing on
mqtt_client.connect()

Connecting to a local MQTT server on port 1883 with parameters:

mqtt_client = MQTT.MQTT(
    broker=secrets["broker"],
    port=secrets["port"],
    socket_pool=pool
)

@brentru
Copy link
Member

brentru commented Mar 5, 2021

Try:

mqtt_client = MQTT.MQTT(
    broker=secrets["broker"],
    port=secrets["port"],
    is_ssl=False,
    socket_pool=pool
)```

@ghayne
Copy link
Author

ghayne commented Mar 5, 2021

Same error I'm afraid!

@lubarb
Copy link

lubarb commented Mar 5, 2021

I'm getting the same error. I edited a copy of adafruit_minimqtt.py to remove the eight lines most recently added, and the error goes away.

Using:

# Set up a MiniMQTT Client
mqtt_client = MQTT.MQTT(
    broker=secrets["mqtt_broker"],
    port=secrets["mqtt_port"],
    username=secrets["mqtt_username"],
    password=secrets["mqtt_password"],
    socket_pool=pool,
    ssl_context=ssl.create_default_context(),
)

@bangell
Copy link

bangell commented Mar 5, 2021

I think i know what this might be.

Im using an insecure port and no logger and it fails because":

line 230:
if self.logger and port == MQTT_TLS_PORT:
self.logger.info(
"Establishing a SECURE SSL connection to {0}:{1}".format(host, port)
)
else:
self.logger.info(
"Establishing an INSECURE connection to {0}:{1}".format(host, port)
)

the problem is the else doesnt check if there is a logger, it crashes becaule logger is none

the work around is to add a logger and it works

Brian

@lubarb
Copy link

lubarb commented Mar 5, 2021

posslbly:

elif self.logger

instead of else?

@wx-watch
Copy link

wx-watch commented Mar 13, 2021

Thanks for posting this, getting the same thing on my Metro ESP32-S2.

Adding

elif self.logger

worked for me. For whatever reason (I'm new to this) configuring a logger for my code.py worked, but still failed for the MQTT module.

@ghayne
Copy link
Author

ghayne commented Mar 13, 2021

@wx-watch - did you pass the logger to minimqtt like this:

import adafruit_logging as logging

mqtt_client = MQTT.MQTT(
    broker=secrets["broker"],
    port=secrets["port"], # Port 1883
    is_ssl=False,
    socket_pool=pool

# Define callbacks etc

mqtt_client.enable_logger(logging)
mqtt_client.connect()

@lubarb
Copy link

lubarb commented Mar 13, 2021

@wx-watch - on further consideration the code:

        if self.logger :
            if port == MQTT_TLS_PORT:
                self.logger.info(
                    "Establishing a SECURE SSL connection to {0}:{1}".format(host, port)
                )
            else:
                self.logger.info(
                    "Establishing an INSECURE connection to {0}:{1}".format(host, port)
                )

is functionally the same but more clearly reflects what's being done.

@wx-watch
Copy link

@ghayne Ah! First time using a logger here. I had not done:
mqtt_client.enable_logger(logging)

...and now it works with the original code. Thanks all!

@brentru
Copy link
Member

brentru commented Mar 17, 2021

@ghayne I do not see this issue anymore since updating to 5.0.5 - do you still see the issue? I tested on an ESP32-S2 Metro and ESP32-S2 MagTag with the latest version of this library

@ghayne
Copy link
Author

ghayne commented Mar 17, 2021

@brentru I missed the update, I'll try it tomorrow. I hate timezones :)

@ghayne
Copy link
Author

ghayne commented Mar 17, 2021

@brentru I couldn't resist trying it - works perfectly, thank you. I'll close the issue.

@ghayne ghayne closed this as completed Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants