Just thought I'd share some experience. In trying to screen mirror between my Android phone and Windows PC, despite some levels of connectivity between the two, screen mirroring (or casting) would not work.
Turned-out the culprit was Smart Steering on the wireless router.
While both devices were connected to the same router, one was on 2.4ghz and the other 5ghz, effectively causing the issue.
Turning off Smart Steering and choosing the same band solved the issue.