Comments (5)
Exactly the same issue here with the ESP32-WROOM-32. Exactly 60 seconds of connection before TCP is dropped and it reconnects to Mosquito.
Issue clearly lies with the ESP32 device since I have quite a large MQTT network and no other devices experience this issue. I have another ESP32 device running ESPHome and using MQTT - this is functioning fine.
from espresense.
I have turned on debug logging on Mosquitto, which is showing some interesting data. I've filtered on 'PING' and 'disconnecting'.
2024-03-24T15:11:38: Received PINGREQ from espresense-office
2024-03-24T15:11:38: Sending PINGRESP to espresense-office
2024-03-24T15:11:49: Received PINGREQ from espresense-office
2024-03-24T15:11:49: Sending PINGRESP to espresense-office
2024-03-24T15:11:59: Received PINGREQ from espresense-office
2024-03-24T15:11:59: Sending PINGRESP to espresense-office
2024-03-24T15:12:24: Client espresense-office has exceeded timeout, disconnecting.
2024-03-24T15:12:38: Received PINGREQ from espresense-office
2024-03-24T15:12:38: Sending PINGRESP to espresense-office
2024-03-24T15:12:49: Received PINGREQ from espresense-office
2024-03-24T15:12:49: Sending PINGRESP to espresense-office
2024-03-24T15:13:24: Client espresense-office has exceeded timeout, disconnecting.
2024-03-24T15:13:38: Received PINGREQ from espresense-office
2024-03-24T15:13:38: Sending PINGRESP to espresense-office
2024-03-24T15:13:48: Received PINGREQ from espresense-office
2024-03-24T15:13:48: Sending PINGRESP to espresense-office
2024-03-24T15:13:59: Received PINGREQ from espresense-office
2024-03-24T15:13:59: Sending PINGRESP to espresense-office
2024-03-24T15:14:24: Client espresense-office has exceeded timeout, disconnecting.
2024-03-24T15:14:38: Received PINGREQ from espresense-office
2024-03-24T15:14:38: Sending PINGRESP to espresense-office
2024-03-24T15:14:49: Received PINGREQ from espresense-office
2024-03-24T15:14:49: Sending PINGRESP to espresense-office
2024-03-24T15:15:00: Received PINGREQ from espresense-office
2024-03-24T15:15:00: Sending PINGRESP to espresense-office
2024-03-24T15:15:24: Client espresense-office has exceeded timeout, disconnecting.
It looks like ESPresence is usually sending a ping around every 11 seconds. Given the default timeout is 15 seconds, this should normally be sufficient.
However, every 3rd or 4th table it doesn't seem to send a ping, with the result that the broker then terminates the connection.
From what I can see, ESPresence doesn't explicitly send pings but leaves it to the underlying library (AsyncMqttClient) here. You can see it sends a ping every timeout * 0.7
(giving 10.5) which matches up to the ~11 seconds.
What isn't clear is what is calling the the onPoll() method that checks whether to send a ping. This comment suggests it's the underlying AsyncTCP library and it should be called every 125ms - question now is to find out whether that's actually happening or not.
The other possibility is that the AsyncMqttClient isn't sending a ping because it thinks there are other messages being sent anyway - next step in debugging is to look for that.
from espresense.
Looking at the AsyncMqttClient library, worryingly it's had no commits since 2022.
The current published release (used by ESPresense) was released in 2021. Since then it looks like there was an attempt to fix the ping code in marvinroger/async-mqtt-client#284 but there is no released version with this code.
Looking at that library, and ASyncTCP, it seems like there have been various issues over time and various half-abandoned forks. Unfortunately I'm not sure where that leaves this because it would be non-trivial to swap out the library from ESPresence. My C++ / TCP / hardware build/debugging is also not good enough to figure out where in the stack this is going wrong without investing a load more time.
from espresense.
I don't suppose any maintainers with familiarity with these areas of code could comment?
from espresense.
Related Issues (20)
- Devices removed and require re-enrollment HOT 8
- Feature request: Provide BLE sensor data to Home Assistant topics for MQTT Discovery
- Automatically Update does nothing HOT 1
- Settings for immediate reaction? HOT 2
- esp32-s3 won't start correctly without serial console HOT 25
- Status LED HOT 4
- Option for a gateway HOT 1
- WebSocket connection Faild for Floorplaner
- ESP32-S3 Boot Loop HOT 1
- Get data from Xiaomi MiJia Bluetooth temperature and humidity sensor hygrothermography model: LYWSDCGQ/01ZM HOT 2
- ESP32 WRoom with sen0395 HOT 1
- Feature Request: add integration for i2c BME680 sensor HOT 3
- Is the ESP32C3SuperMini supported? HOT 2
- Issue Description for ESP32 MQTT Issue with ESPresense Adapter:
- Hidden 40 MHz wide SSID broadcast whilst connected to main AP anyway - request disable local AP mode entirely
- Support for ESP32-C6 HOT 5
- [BUG] Stack overflow in "TMR SVC" Task - Random crash and reboot HOT 1
- Enrolling iOS device does not work in MD5Atom version HOT 1
- Radar sensor: Hi-Link LD2450 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espresense.