← index #410Issue #309
Off-topic · high · value 1.216
QUERY · ISSUE

UMQTT - mqtt stops publishing after 5 minutes

openby TanCansopened 2021-01-27updated 2021-01-27

Hello everyone,

i am using umqtt library to publish some telemetry data to an IoT platform with a pycom microcontroller. But mqtt stops publishing data exact after five minutes even though it is still connected to wlan.

I am sharing the piece of code that calls mqtt client and the library

Connecting wlan:

wlan.connect('my wlan', auth=(None,'my password'), timeout= 50000) #even though i changed this timeout it didnt solve my problem

My credentials (for iot platform)

server = 'my server'
port = 1883
id = 'my id'
pw = ‘acces token’
topic_publish = 'v1/devices/me/telemetry'
dict={}

Creating a client:

Client = MQTTClient(id, server, port, pw, pw)
time.sleep(2)
client.connect()

Publishing in the loop:

While 1
encoded=ujson.dumps(dict)
client.publish(topic_publish, encoded)
time.sleep(1)

Umqtt library:

umqtt.txt

Thank you all in advance!

CANDIDATE · ISSUE

a problem with the publication

closedby novikovav69opened 2018-10-03updated 2018-10-07

Hello!
I have a problem with the publication.
I do:
from umqtt.simple import MQTTClient
client = MQTTClient(client_id="ESP8266", server="192.168.100.10", port=1883)
client.connect
client.publish("in", "sHOW")

I receive:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "umqtt/simple.py", line 123, in publish
AttributeError: 'NoneType' object has no attribute 'write'

2 comments
SpotlightKid · 2018-10-03

@novikovav69 MQTTClient.connect is a method, you need to call it.You are missing the parentheses after client.connect.

novikovav69 · 2018-10-07

Many thanks! Forgive me my carelessness.

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