Avoid errors when connection is reset (as when using self-signed certificate for wss)