knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

Intermittent Disconnects with TinyGSM + SSLClient + PubSubClient during MQTT Ping #1060

Open k3341095 opened 1 week ago

k3341095 commented 1 week ago

Hello,

I am experiencing an issue with my project using TinyGSM, SSLClient, and PubSubClient libraries where the MQTT connection randomly disconnects. The disconnects seem to occur specifically when the 15-second MQTT ping interval happens. Until the ping, the MQTT communication works fine.

Below is a snippet from the stream writer log showing the issue:

18:13:52.390 > AT+CIPSEND=0,31
18:13:52.393 >
18:13:52.393 > >������h[׵͑� [295404][E][ssl__client.cpp:193] client_net_send(): write failed
18:13:53.403 > [295410][E][ssl__client.cpp:46] _handle_error(): [send_ssl_data():900]: (-78) Failed to send data - underlying network layer error
18:13:53.414 > [295422][E][SSLClient.cpp:384] write(): Error sending data to SSL connection. Stopping SSLClient...
18:13:53.423 > AT+CIPCLOSE=0
18:13:53.600 >

From what I understand, the error happens when trying to send the ping packet, leading to the connection being dropped. This issue does not occur at any other time, so I suspect it's related to the ping mechanism.

Questions: What could be causing the failure specifically during the ping interval? Should I consider increasing the keepalive interval or adjusting the timeout values? Are there specific areas or settings in TinyGSM, SSLClient, or PubSubClient that I should investigate to resolve this issue? Additional Information: The network connection itself seems stable as there are no disconnects during regular MQTT operations, only during the ping. I have already tried different baud rates and checked for hardware issues, but the problem persists. Any help or guidance on this issue would be greatly appreciated.

Thank you!