DIAGNOSIS The most common setup blocker is your phone being on a different Wi-Fi band (5GHz) than the Ray (2.4GHz only). Your phone and the Ray need to be on the same 2.4GHz network to communicate during setup.
FIX 1) Temporarily turn off the 5GHz band on your router (you can turn it back on later). How to do this is in your router's manual, but it's usually a quick toggle in its wireless settings. 2) Make sure your phone is connected to the 2.4GHz Wi-Fi. 3) Now, restart the Sonos app setup process from the beginning. It should find the Ray immediately. Follow the prompts to finish.
IF THAT DIDN'T WORK Firewall or security software on your phone or router might be blocking the discovery signal. Try temporarily disabling any "VPN" or "Security" apps on your phone during setup. Also, if you have a "Guest Network" enabled on your router, make sure you're not connected to it—use your main network.
HEADS UP Once the Ray is fully set up and playing music, you can re-enable your router's 5GHz band. Your phone can then use 5GHz for internet, but the Ray will stay on 2.4GHz for its connection—that's perfectly normal and won't break anything.