← all posts site ↗

the tv cast that heals itself

the tv cast hotkey went finicky again. press the shortcut on a youtube tab, the url bar pops up exactly like normal, and then nothing reaches the tv. reloaded the whole script from the tray, still nothing. the classic it used to work, so what changed pattern, and the answer was not where the symptom pointed.

the pc side was never the problem. the server log showed every attempt arriving. the real break was the tv: it had slept for a long stretch and that dropped the direct control link between the server and the tv. the tv itself was on and its port answered just fine, but the control session was gone. and the cast script had a bug for exactly this situation. when the port is open it skipped the connect step entirely, so it never re-established anything, and every cast died at the last step with device not found.

patched it to check the control link and reconnect on every single cast. then tested the exact failure mode on purpose: killed the live transport, ran the wake path, and watched it notice the link was missing, reconnect, and exit clean. a second run came back clean with no noise at all. the tv's long sleeps were doing the same damage every time, and now the repair lives inside the cast itself instead of being a manual ritual you remember after the third failure.