fixed hanging issue when TCP connection was closed