diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 5bd6020c92..b7336e1505 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -752,8 +752,28 @@ void DomainServer::setupICEHeartbeatForFullNetworking() { } void DomainServer::updateICEServerAddresses() { - if (_iceAddressLookupID == -1) { + if (_iceAddressLookupID == INVALID_ICE_LOOKUP_ID) { _iceAddressLookupID = QHostInfo::lookupHost(_iceServerAddr, this, SLOT(handleICEHostInfo(QHostInfo))); + + // there seems to be a 5.9 bug where lookupHost never calls our slot + // so we add a single shot manual "timeout" to fire it off again if it hasn't called back yet + static const int ICE_ADDRESS_LOOKUP_TIMEOUT_MS = 5000; + QTimer::singleShot(ICE_ADDRESS_LOOKUP_TIMEOUT_MS, this, &DomainServer::timeoutICEAddressLookup); + } +} + +void DomainServer::timeoutICEAddressLookup() { + if (_iceAddressLookupID != INVALID_ICE_LOOKUP_ID) { + // we waited 5s and didn't hear back for our ICE DNS lookup + // so time that one out and kick off another + + qDebug() << "IP address lookup timed out for" << _iceServerAddr << "- retrying"; + + QHostInfo::abortHostLookup(_iceAddressLookupID); + + _iceAddressLookupID = INVALID_ICE_LOOKUP_ID; + + updateICEServerAddresses(); } } diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 03ad76d313..52ac435517 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -39,6 +39,8 @@ typedef QMultiHash TransactionHash; using Subnet = QPair; using SubnetList = std::vector; +const int INVALID_ICE_LOOKUP_ID = -1; + enum ReplicationServerDirection { Upstream, Downstream @@ -114,6 +116,8 @@ private slots: void tokenGrantFinished(); void profileRequestFinished(); + void timeoutICEAddressLookup(); + signals: void iceServerChanged(); void userConnected(); @@ -223,7 +227,7 @@ private: QList _iceServerAddresses; QSet _failedIceServerAddresses; - int _iceAddressLookupID { -1 }; + int _iceAddressLookupID { INVALID_ICE_LOOKUP_ID }; int _noReplyICEHeartbeats { 0 }; int _numHeartbeatDenials { 0 }; bool _connectedToICEServer { false };