Esp32 OTA fails despite working with web browser

I have loaded the esp32 (over USB initially) with the ElegantOTA examples and it works perfectly if I connect to the device with a web browser over WiFi and upload a .bin file but I can’t get it to work from PlatformIO direct.

Checking with Wireshark, Platformio is attempting to connect to the correct port on the esp32 via WiFi but with UDP. Is there a setting I need to put in Platformio.ini or somewhere else to make it use TCP?
mDNS is resolving to the correct IP address.

I have spent some time hunting for this and have found many problems associated with esp32 OTA (and fixes for most) but can find no reference to “upload_protocol = espota” using UDP or TCP.

This is my Platformio.ini file:

[env:esp12e]
platform = espressif32
board = nodemcu-32s
framework = arduino
lib_deps =
marvinroger/AsyncMqttClient@^0.9.0
ottowinter/ESPAsyncWebServer-esphome@^3.1.0
ayushsharma82/ElegantOTA@^3.1.0
upload_protocol = espota
upload_port = esp32-chint.local
upload_flags = --port=80
#upload_port = /dev/ttyUSB0
#upload_speed = 921600
monitor_speed = 115200
build_flags=-DELEGANTOTA_USE_ASYNC_WEBSERVER=1

John.

Custom fancy shmancy OTA libraries need their custom fancy shmancy upload scripts. The repo https://github.com/ayushsharma82/ElegantOTA has platformio_upload.py for that purpose. You have to follow their instructions to use it.

This would work if you used the builtin ArduinoOTA library, which you are not.

Thanks very much Max. Working now.

I tried using the builtin ArduinoOTA library first but there were several dependency problems within the library that stopped it compiling so I just looked for a different one and this was the first I tried. I didn’t spot that it needed the extra fancy shmancy script to actually make it work.

Best regards
John.