Added a check for timeouts when waiting for frames from the server.
The current implementation doesn't handle the timeouts in any way and just tries again after 5 seconds.