Add delay to receive(). Avoid closed connection exception.