Connection Timeout on channel?

Joe on 21 Jun 2023
Latest activity Reply by Joe on 21 Jun 2023

Using mqtt3.thingspeak.com, initially everything works well. but it appears the connection is disconnected after a period of inactivity. Is this expected? Is there a workaround? is some kind of keepalive expected?
Traceback (most recent call last):
File "microdot_asyncio.py", line 368, in dispatch_request
File "microdot_asyncio.py", line 432, in _invoke_handler
File "main.py", line 39, in toggle_led
File "umqtt/simple.py", line 134, in publish
OSError: [Errno 128] ENOTCONN
Christopher Stapels
Christopher Stapels on 21 Jun 2023
I would not expect that if your Wi-Fi connection is strong and constant. In our example code, we may not be sensitive to that effect, however.
In this MQTT Arduino example, if the connection is lost a new one is recreated. I don’t remember the reconnection happening consistently when we tested that code, but I’m not sure the time frame that you are seeing the reconnection required. How long in general do you wait before you see this issue?
Joe
Joe on 21 Jun 2023 (Edited on 21 Jun 2023)
Appears to be around a minute or so. Was hoping that setting the keepalive parameter in the MQTT client would clear things up, but no luck:
Traceback (most recent call last):
File "microdot_asyncio.py", line 368, in dispatch_request
File "microdot_asyncio.py", line 432, in _invoke_handler
File "main.py", line 40, in toggle_led
File "umqtt/simple.py", line 134, in publish
OSError: [Errno 104] ECONNRESET
Christopher Stapels
Christopher Stapels on 21 Jun 2023 (Edited on 21 Jun 2023)
I just ran a test with mqttx conencted to ThingSpeak, and I did not get disconnected and my subscriptions ran every time at one minute, four minutes and five minutes. Here are the publish results, with no disconnects (and no auto refresh of the conenction)
Keep alive appears to be set at 60 for this conenction.
Joe
Joe on 21 Jun 2023
I too do not see the issue using MQTTX. Seems to be something with micropython's umqtt I'm not doing correctly. Will look into it. Thanks.
Joe
1
Post
2
Replies

Tags

No tags entered yet.