output if pinged node cannot be reached

This commit is contained in:
Stephen Birarda 2015-05-28 11:22:27 -07:00
parent cee058c4ce
commit 81c23e9ca0
3 changed files with 14 additions and 4 deletions

View file

@ -57,7 +57,7 @@ public:
int getConnectionAttempts() const { return _connectionAttempts; } int getConnectionAttempts() const { return _connectionAttempts; }
void incrementConnectionAttempts() { ++_connectionAttempts; } void incrementConnectionAttempts() { ++_connectionAttempts; }
void resetConnectionAttemps() { _connectionAttempts = 0; } void resetConnectionAttempts() { _connectionAttempts = 0; }
void recordBytesSent(int count); void recordBytesSent(int count);
void recordBytesReceived(int count); void recordBytesReceived(int count);

View file

@ -119,6 +119,9 @@ void Node::setActiveSocket(HifiSockAddr* discoveredSocket) {
// we have an active socket, stop our ping timer // we have an active socket, stop our ping timer
stopPingTimer(); stopPingTimer();
// we're now considered connected to this peer - reset the number of connection attemps
resetConnectionAttempts();
} }
void Node::activateLocalSocket() { void Node::activateLocalSocket() {

View file

@ -475,7 +475,7 @@ void NodeList::handleICEConnectionToDomainServer() {
if (_domainHandler.getICEPeer().isNull() if (_domainHandler.getICEPeer().isNull()
|| _domainHandler.getICEPeer().getConnectionAttempts() >= MAX_ICE_CONNECTION_ATTEMPTS) { || _domainHandler.getICEPeer().getConnectionAttempts() >= MAX_ICE_CONNECTION_ATTEMPTS) {
_domainHandler.getICEPeer().resetConnectionAttemps(); _domainHandler.getICEPeer().resetConnectionAttempts();
flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendICEServerHearbeat); flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendICEServerHearbeat);
@ -588,6 +588,13 @@ void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) {
flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendAudioPing); 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 // send the ping packet to the local and public sockets for this node
QByteArray localPingPacket = constructPingPacket(PingType::Local); QByteArray localPingPacket = constructPingPacket(PingType::Local);
writeDatagram(localPingPacket, node, node->getLocalSocket()); writeDatagram(localPingPacket, node, node->getLocalSocket());
@ -615,10 +622,10 @@ void NodeList::startNodeHolePunch(const SharedNodePointer& node) {
} }
void NodeList::handleNodePingTimeout() { void NodeList::handleNodePingTimeout() {
Node* senderNode = qobject_cast<Node*>(sender()); SharedNodePointer senderNode = nodeWithUUID(qobject_cast<Node*>(sender())->getUUID());
if (senderNode) { if (senderNode) {
pingPunchForInactiveNode(nodeWithUUID(senderNode->getUUID())); pingPunchForInactiveNode(senderNode);
} }
} }