Fix bug on socket timeout