Using websockets with a UNO R4 Wifi

what error message did you get - upload as text
what WebServer.h library are you using? e.g. it looks like WebServer.h is an ESP32 library
although the UNO WiFi R4 has an onboard ESP32-S3 you don't appear to have direct access to run code on it - see web-server-on-uno-r4-wifi
have a look at uno-r4-library-compatibility