fix bug for socket closed