Closed rpavlik closed 3 years ago
@rpavlik can you open an issue in the circup repo explaining what didn't work. I've been working on it lately. Ty!
@rpavlik If this is the issue you saw https://github.com/adafruit/circup/issues/75. Circup has been fixed and released, new version is 0.9.0
OK, so that fixed the circup issue (though I was getting filename corruption if I tried installing all the libraries). I started fresh with an erased filesystem and just the stuff I absolutely need. Here's what circup freeze says I have:
And unfortunately this problem still happens
Ah, it was defaulting to use tls/port 8883, which is at least part of it.
Unfortunately, it's now just failing in the other half of the condition.
Traceback (most recent call last):
File "code.py", line 90, in <module>
File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 316, in connect
File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 316, in connect
MMQTTException: ('Invalid broker address defined/could not connect: broker 192.186.1.150, port 1883', RuntimeError('ESP32 not responding',))
Tried re-flashing the esp32, then using the basic outline of the wifi test code. Looked the same as what I was using, but without the wifi manager. This does appear to work, at least after I properly re-type the IP address of my broker. Turning other code back on bit-by-bit.
Which version of nina-fw (https://github.com/adafruit/nina-fw) is running on your ESP32?
1.7.1, tested reinstalling. Thought I had added results, but I guess not. Trying to figure out how I got it to fail, since it's working now (though the scd30 is erroring, might be too much current or something?)
OK, I think this was mostly about missing the detail that it assumes SSL and port 8883 by default. The exception message might be a bit more useful (they're already split so wouldn't be too bad to adjust) for folks who have no ssl inside their lan, but it appears like it's not actually anything to do with the wifi manager or the matrixportal library or anything.
ah, I was behind by 1 major release. Now it errors different if you get the ssl-ness wrong. Maybe edit line 272 so that it says "Are you sure your broker uses SSL?" if it was defaulting to SSL?
@rpavlik Yeah, the client assumes you are using SSL. You may un-set it via the initializer.
Now it errors different if you get the ssl-ness wrong.
What does this error look like - could you copy/paste the output from the repl here?
>>> # Set up a MiniMQTT Client
>>> mqtt_client = MQTT.MQTT(
... broker=secrets["broker"],
... # is_ssl=secrets["mqttssl"]
... #port=secrets["brokerPort"],
... # log=True
... )
>>> mqtt_client.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 467, in connect
File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 272, in _get_socket
RuntimeError: Sending request failed
>>>
with the latest version of everything according to circup.
I was able to connect to test.mosquitto.org using its numeric IP address ('broker': "5.196.95.208", 'port': 1883).
# Set up a MiniMQTT Client
mqtt_client = MQTT.MQTT(
broker=secrets["broker"],
port=1883
)
Are other devices on your local network (MQTT client on a phone, laptop, tablet) able to see the Mosquitto broker?
Have you tried "exposing" the server using something like NGROK (https://ngrok.com)?
Thanks for being patient - I'd like to find this bug.
I can connect to it if I specify the port - see commented out code in requested repl log. I think the only "bug" here is that it was hard for me to figure out that the default was SSL and that's why the connection failed.
I see - let me if we can raise
an error anywhere or can send a message to the logger.
Addressed in #71, closing
I'm using a MatrixPortal successfully connected to wifi, on a network with a mosquitto mqtt server, no authentication or security on that. circuitpython 6.1.0, latest library bundle (I think - circup isn't working for me today, but I hand-selected the libraries I think I needed and copied them manually from the bundle), latest nina firmware on esp32, mqtt broker is specified by ip (v4) address in the secrets file.
Chopped down code:
(Yes, I'm initially just trying to just read a pressure from another sensor in my network, since I'm porting some code from the Clue. Just trying to get my scd30 and pm25 sensor submitting to mqtt and thus influxdb and grafana, in addition to a local display :D )
I get this output:
Line 97 is the mqtt connect line at the end of the cut down code.
Resembles #50 but not sure if it's the same. Hardware reset doesn't seem to help.
(Is this the right place for these kinds of "Seems like this should work, but I might be doing it wrong" questions, or would you prefer forums or discord?)