maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.1k stars 169 forks source link

Fixes No Response issue on ESP32 #85

Closed pbendersky closed 5 years ago

pbendersky commented 5 years ago

See issue #84 that I reported.

To reproduce it, on fresh install I'd run curl -v 192.168.1.56:5556/characteristics?id=1.10 several times (my device has that characteristic present). After about 10 times, homekit_server_accept_client starts failing because the accept call returns < 0. After inspection, the errno set is 23, which means the socket is not getting properly closed.

As per https://github.com/espressif/esp-idf/pull/537, it seems that instead of lwip_close we need to be calling lwip_close_r, for threading issues. Since lwip_close_r is not present in esp-open-rtos, I changed the calls to close, that map to lwip_close on ESP8266 and to lwip_close_r on ESP32.

This fixed my "No Response" issue on an ESP32.

maximkulkin commented 5 years ago

Thank you for investigating this. I will recheck that this change does not break ESP8266 functionality and merge ASAP

maximkulkin commented 5 years ago

BTW with repro steps you’ve mentioned, do you actually get a meaningful response? Because tou access encryption protected API without encryption and should always get 401 or 403. That said, it does not matter which URL you access, you just need to connect and then disconnect.

I’ve merged an extended version of this fix, so it should be fine now. Closing this one.

pbendersky commented 5 years ago

I do get a JSON, not 401 or 403. Saw the fix, thank you!