improve persistent connection issue: add timer to close the socket if it is timed out