fix expect behavior

Fix expect behavior to attempt to read from the socket max_retries times.