← index #556Issue #908
Related · high · value 0.445
QUERY · ISSUE

Raspberry Pi Pico W - umqtt clean_session=False -[Errno 12] ENOMEM

openby Zuroyopened 2022-10-25updated 2023-07-22

Hello,
I'm using a raspberry pi pico w to connect to a mqtt server. The clean sesssion connection works pretty well but when I try to use client.connect(False) it returns the error: OSError: [Errno 12] ENOMEM

Here a snippet of the code:

`
from umqtt.robust import MQTTClient
def mqtt_connect():

client = MQTTClient(client_id, mqtt_server, port, username, pwd,  keepalive=3600)
client.set_callback(on_message)
client.on_message = on_message
while (client.connect(False) != 0):
    print('Waiting for MQTT connection...')
    sleep(1)
print('Connected to %s MQTT Broker'%(mqtt_server))
client.subscribe(topic_sub)
print("Connected to %s, subscribed to %s topic" % (mqtt_server, topic_sub))

return client

`
and the Error:

Waiting for MQTT connection...
Waiting for MQTT connection...
Waiting for MQTT connection...
Waiting for MQTT connection...
Waiting for MQTT connection...
Traceback (most recent call last):
File "<stdin>", line 189, in <module>
File "<stdin>", line 71, in mqtt_connect
File "/lib/umqtt/simple.py", line 66, in connect
OSError: [Errno 12] ENOMEM

Can you help me please?

Thanks

1 comment
kdesimini · 2023-07-22

Also seeing this issue when trying to connect on the pico.

CANDIDATE · ISSUE

AttributeError: 'NoneType' object has no attribute 'write'

closedby Ugthakopened 2024-08-14updated 2024-08-14

Hello there,

I'm currently trying to send a message from my Raspberry Pi Pico W to my Node-Red through MQTT.simple with the following snippet of code:

while True:
pin_state = gpio_pin.value()
print(f"Pin state: {pin_state}")
client.publish(MQTT_TOPIC, str(pin_state))
time.sleep(1)

"pin_state" is working as intended so I have no problems collecting the data I wish to but when I run the program I always get the error:
AttributeError: 'NoneType' object has no attribute 'write'

there was a issue previously where someone was suffering from the same issue and the two replies stated that you needed to connect to the broker first, which I have confirmed I am doing, and that it's possible that there isn't a connection to the broker at all; I believe there to be a connection between my Pi and the Broker because no errors are presented and the node within Node-Red does react to the connection.

If any more information is needed to help me, please do ask and I look forward to any help given!

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied