Fix the bug that the socket closed after getting inputstream