diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 47d629a8f1..24d2d4812e 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -1331,10 +1331,6 @@ void DomainServer::pingPunchForConnectingPeer(const SharedNetworkPeer& peer) { } else { auto nodeList = DependencyManager::get(); - // send ping packets to this peer's interfaces - qDebug() << "Sending ping packets to establish connectivity with ICE peer with ID" - << peer->getUUID(); - // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = nodeList->constructPingPacket(PingType::Local, false); nodeList->writeUnverifiedDatagram(localPingPacket, peer->getLocalSocket()); @@ -1377,6 +1373,10 @@ void DomainServer::processICEPeerInformation(const QByteArray& packet) { // immediately ping the new peer, and start a timer to continue pinging it until we connect to it newPeer->startPingTimer(); + + qDebug() << "Sending ping packets to establish connectivity with ICE peer with ID" + << newPeer->getUUID(); + pingPunchForConnectingPeer(newPeer); } else { delete receivedPeer; diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 24a9225374..26cd3f1425 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -499,17 +499,18 @@ void NodeList::pingPunchForDomainServer() { // check if we've hit the number of pings we'll send to the DS before we consider it a fail const int NUM_DOMAIN_SERVER_PINGS_BEFORE_RESET = 2000 / UDP_PUNCH_PING_INTERVAL_MS; - if (_domainHandler.getICEPeer().getConnectionAttempts() > 0 - && _domainHandler.getICEPeer().getConnectionAttempts() % NUM_DOMAIN_SERVER_PINGS_BEFORE_RESET == 0) { - // if we have then nullify the domain handler's network peer and send a fresh ICE heartbeat + if (_domainHandler.getICEPeer().getConnectionAttempts() == 0) { + qCDebug(networking) << "Sending ping packets to establish connectivity with domain-server with ID" + << uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID()); + } else { + if (_domainHandler.getICEPeer().getConnectionAttempts() % NUM_DOMAIN_SERVER_PINGS_BEFORE_RESET == 0) { + // if we have then nullify the domain handler's network peer and send a fresh ICE heartbeat - _domainHandler.getICEPeer().softReset(); - handleICEConnectionToDomainServer(); + _domainHandler.getICEPeer().softReset(); + handleICEConnectionToDomainServer(); + } } - qCDebug(networking) << "Sending ping packets to establish connectivity with domain-server with ID" - << uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID()); - flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendPingsToDS); // send the ping packet to the local and public sockets for this node