Handle case where getHostName returns null or an exception by falling back to the nodeName