Added timeout for requests, handle empty responses when server closes connection.