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:

platform = espressif32
board = nodemcu-32s
framework = arduino
lib_deps =
upload_protocol = espota
upload_port = esp32-chint.local
upload_flags = --port=80
#upload_port = /dev/ttyUSB0
#upload_speed = 921600
monitor_speed = 115200


Custom fancy shmancy OTA libraries need their custom fancy shmancy upload scripts. The repo has 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