Emitting 'close' and 'error' on the server.