Added timeouts to prevent connection hanginng on connection loss