Please add if () conditional wrapper to check if REMOTE_ADDR is not set prior to firing off setRemoteIp() method.