Fix a bug when the server close a connection