Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin crashes with Invalid mbox on esp32 due to MQTT connecting too early #865

Open
jbaudoux opened this issue Dec 22, 2024 · 1 comment
Labels

Comments

@jbaudoux
Copy link

Describe the bug

On ESP32, you cannot open a socket if the network is not established. This means that you cannot start the mqtt connection if the network is not connected. Error message at boot is:
assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)

Bug is in MqttClient::begin() that connects without checking network here
https://github.com/sidoh/esp8266_milight_hub/blob/master/lib/MQTT/MqttClient.cpp#L55
That reconnect() line should be removed.

The mqtt connection will be established in the loop when calling MqttClient::handleClient() after checking the network connection here https://github.com/sidoh/esp8266_milight_hub/blob/master/src/main.cpp#L531
i think there is no need to connect in begin.

Steps to reproduce

I guess it depends how fast the network is established.

Expected behavior

Should not crash in begin

Setup information

Firmware version

1.13.1

Output of http://milight-hub.local/about

{"firmware":"milight-hub","version":"1.13.1-beta2","ip_address":"172.19.3.37","reset_reason":"7","variant":"esp32","free_heap":215768,"arduino_version":"v4.4.6-dirty","free_stack":5548,"flash_used":2259,"flash_total":113201,"flash_pct_free":98,"mqtt":{"configured":true,"connected":true,"status":"Connected"},"queue_stats":{"length":0,"dropped_packets":0}}

Output of http://milight-hub.local/settings

{"admin_username":"","admin_password":"","ce_pin":4,"csn_pin":5,"reset_pin":0,"led_pin":-2,"radio_interface_type":"nRF24","packet_repeats":50,"http_repeat_factor":1,"auto_restart_period":0,"mqtt_server":"172.19.3.140","mqtt_username":"","mqtt_password":"","mqtt_topic_pattern":"milight/commands/:device_id/:device_type/:group_id","mqtt_update_topic_pattern":"","mqtt_state_topic_pattern":"milight/state/:device_id/:device_type/:group_id","mqtt_client_status_topic":"milight/client_status","simple_mqtt_client_status":true,"discovery_port":48899,"listen_repeats":3,"state_flush_interval":10000,"mqtt_state_rate_limit":500,"mqtt_debounce_delay":500,"mqtt_retain":true,"packet_repeat_throttle_sensitivity":0,"packet_repeat_throttle_threshold":200,"packet_repeat_minimum":3,"enable_automatic_mode_switching":false,"led_mode_wifi_config":"Fast toggle","led_mode_wifi_failed":"On","led_mode_operating":"Slow blip","led_mode_packet":"Flicker","led_mode_packet_count":3,"hostname":"milight-hub","rf24_power_level":"MAX","rf24_listen_channel":"LOW","wifi_static_ip":"","wifi_static_ip_gateway":"","wifi_static_ip_netmask":"","packet_repeats_per_loop":10,"home_assistant_discovery_prefix":"homeassistant/","wifi_mode":"g","default_transition_period":500,"rf24_channels":["LOW","MID","HIGH"],"device_ids":[],"gateway_configs":[],"group_state_fields":["state","brightness","computed_color","mode","color_temp","color_mode"],"ignored_listen_protocols":[]}

Additional context

Board: esp32dev
Build with pio run --target upload -e esp32

@jbaudoux jbaudoux added the bug label Dec 22, 2024
@jbaudoux
Copy link
Author

MDNS also fails - reported here #866

@jbaudoux jbaudoux changed the title Begin crashes with Invalid mbox on esp32 Begin crashes with Invalid mbox on esp32 due to MQTT connecting too early Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant