client: Use timeouts and deadlines to avoid hanging. Fixes #154