meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.26k stars 787 forks source link

[Bug]: Unable to reconnect to mqtt with tls after wireless beacon timeout #2483

Closed zarya closed 1 year ago

zarya commented 1 year ago

Category

WiFi

Hardware

Not Applicable

Firmware Version

v1-2.1.11.5ec624d

Description

Node is unable to reconnect to MQTT (TLS) after wireless reconnection.

Relevant log output

INFO  | 05:35:13 898 [mqtt] Received MQTT topic msh/2/c/<removed>/!<removed>, len=76
[910880][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[910881][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 200 - BEACON_TIMEOUT
[910884][D][WiFiGeneric.cpp:1077] _eventCallback(): WiFi Reconnect Running
[910894][E][ssl_client.cpp:37] _handle_error(): [send_ssl_data():382]: (-78) UNKNOWN ERROR CODE (004E)
DEBUG | 05:35:25 910 WiFi-Event 5: Disconnected from WiFi access point
DEBUG | 05:35:25 910 [Router] Found existing packet record for fr=<removed>,to=0xffffffff,id=<removed>
DEBUG | 05:35:25 910 [Router] Found existing packet record for fr=<removed>,to=0xffffffff,id=<removed>
DEBUG | 05:35:25 910 [Router] Add packet record (id=<removed> fr=0xf0 to=0xff, WantAck=0, HopLim=6 Ch=0x0 Portnum=67 rxtime=1683783312 priority=1)
DEBUG | 05:35:25 910 [Router] Ignoring incoming msg, because we've already seen it (id=<removed> fr=0xf0 to=0xff, WantAck=0, HopLim=6 Ch=0x0 Portnum=67 rxtime=1683783312 priority=1)
DEBUG | 05:35:25 910 [Router] Incoming message was filtered <removed>
DEBUG | 05:35:25 910 [RadioIf] Completed sending (id=<removed> fr=0xf0 to=0xff, WantAck=0, HopLim=6 Ch=0xee encrypted rxtime=1683783312 priority=1)
INFO  | 05:35:26 911 [WifiConnect] Reconnecting to WiFi access point issues
[917780][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
DEBUG | 05:35:32 917 WiFi-Event 4: Connected to access point
[918424][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[918425][D][WiFiGeneric.cpp:1098] _eventCallback(): STA IP: <removed>, MASK: 255.255.255.0, GW: <removed>
DEBUG | 05:35:32 918 WiFi-Event 7: Obtained IP address: Using TLS-encrypted session
INFO  | 05:35:32 918 Connecting to MQTT server <removed>, port: 8883, username: <removed>, password: <removed>
[918492][D][ssl_client.cpp:176] start_ssl_client(): WARNING: Skipping SSL Verification. INSECURE!
[918493][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():264]: (-32512) SSL - Memory allocation failed
[918500][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -32512
ERROR | 05:35:32 918 Failed to contact MQTT server (1/5)...
zarya commented 7 months ago

This issue still exists in version 2.2.19.8f6a283

garthvh commented 7 months ago

Check your mqtt config. Are you running a private server with a cert for this?

zarya commented 7 months ago

Yes i am, server used is EMQX the cert is self signed first connect after reboot it works flawless but after it reconnects wifi it stops working and trows the mem allocation failed msg.

tavancini commented 7 months ago

Same here: T-Beam v1.1 SX1268 433/470Mhz

Trying to connect to a public MQTT server in Brazil:

INFO  | 16:44:51 14340 [mqtt] Using TLS-encrypted session
INFO  | 16:44:51 14340 [mqtt] Attempting to connect directly to MQTT server platform.meshbrasil.com, port: 1883, username: meshdev, password: large4cats
[14340499][D][ssl_client.cpp:176] start_ssl_client(): WARNING: Skipping SSL Verification. INSECURE!
[14340500][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():264]: (-32512) SSL - Memory allocation failed

Already tried v2.2.19 and v2.2.17, both have this problem.

oherrala commented 4 months ago

This might be related to #3496.