diff --git a/lib/core/common.py b/lib/core/common.py index 3e8603a4d..3f65b0125 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -928,12 +928,18 @@ def getDelayQuery(andCond=False): return query def getLocalIP(): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((conf.hostname, conf.port)) - ip, _ = s.getsockname() - s.close() + retVal = None + try: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((conf.hostname, conf.port)) + retVal, _ = s.getsockname() + s.close() + except: + debugMsg = "there was an error in opening socket " + debugMsg += "connection toward '%s'" % conf.hostname + logger.debug(debugMsg) - return ip + return retVal def getRemoteIP(): return socket.gethostbyname(conf.hostname)