From 81c23e9ca0188a7817e47012f17dd812a5bb04e2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 28 May 2015 11:22:27 -0700 Subject: [PATCH] output if pinged node cannot be reached --- libraries/networking/src/NetworkPeer.h | 2 +- libraries/networking/src/Node.cpp | 3 +++ libraries/networking/src/NodeList.cpp | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libraries/networking/src/NetworkPeer.h b/libraries/networking/src/NetworkPeer.h index 2a060408c1..92f271efa4 100644 --- a/libraries/networking/src/NetworkPeer.h +++ b/libraries/networking/src/NetworkPeer.h @@ -57,7 +57,7 @@ public: int getConnectionAttempts() const { return _connectionAttempts; } void incrementConnectionAttempts() { ++_connectionAttempts; } - void resetConnectionAttemps() { _connectionAttempts = 0; } + void resetConnectionAttempts() { _connectionAttempts = 0; } void recordBytesSent(int count); void recordBytesReceived(int count); diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index f651553ff6..e4144d080c 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -119,6 +119,9 @@ void Node::setActiveSocket(HifiSockAddr* discoveredSocket) { // we have an active socket, stop our ping timer stopPingTimer(); + + // we're now considered connected to this peer - reset the number of connection attemps + resetConnectionAttempts(); } void Node::activateLocalSocket() { diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 7384457458..0838ec18ec 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -475,7 +475,7 @@ void NodeList::handleICEConnectionToDomainServer() { if (_domainHandler.getICEPeer().isNull() || _domainHandler.getICEPeer().getConnectionAttempts() >= MAX_ICE_CONNECTION_ATTEMPTS) { - _domainHandler.getICEPeer().resetConnectionAttemps(); + _domainHandler.getICEPeer().resetConnectionAttempts(); flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendICEServerHearbeat); @@ -588,6 +588,13 @@ void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) { flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendAudioPing); } + // every second we're trying to ping this node and we're not getting anywhere - debug that out + const int NUM_DEBUG_CONNECTION_ATTEMPTS = 1000 / (UDP_PUNCH_PING_INTERVAL_MS); + + if (node->getConnectionAttempts() > 0 && node->getConnectionAttempts() % NUM_DEBUG_CONNECTION_ATTEMPTS == 0) { + qCDebug(networking) << "No response to UDP hole punch pings for node" << node->getUUID() << "in last second."; + } + // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = constructPingPacket(PingType::Local); writeDatagram(localPingPacket, node, node->getLocalSocket()); @@ -615,10 +622,10 @@ void NodeList::startNodeHolePunch(const SharedNodePointer& node) { } void NodeList::handleNodePingTimeout() { - Node* senderNode = qobject_cast(sender()); + SharedNodePointer senderNode = nodeWithUUID(qobject_cast(sender())->getUUID()); if (senderNode) { - pingPunchForInactiveNode(nodeWithUUID(senderNode->getUUID())); + pingPunchForInactiveNode(senderNode); } }