From 512b43e1de99f113a8b5ec8ee59bf0e4f6be8236 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 4 Jun 2019 15:18:38 -0700 Subject: [PATCH 1/4] Log socket error string when socket error happens --- libraries/networking/src/udt/Socket.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 524f7edf72..5e68070bb7 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -486,7 +486,11 @@ std::vector Socket::getConnectionSockAddrs() { } void Socket::handleSocketError(QAbstractSocket::SocketError socketError) { - qCDebug(networking) << "udt::Socket error - " << socketError; + qCDebug(networking) << "udt::Socket (" << _udpSocket.state() << ") error - " << socketError << "(" << _udpSocket.errorString() << ")"; +#ifdef DEBUG_EVENT_QUEUE + int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread()); + qCDebug(networking) << "Networking queue size - " << nodeListQueueSize; +#endif // DEBUG_EVENT_QUEUE } void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) { From 06ed751f56542fd79b286fc687f225e54deaf73c Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Wed, 5 Jun 2019 11:08:12 -0700 Subject: [PATCH 2/4] checkpoint to deal with merge --- libraries/networking/src/LimitedNodeList.cpp | 6 +++++- libraries/networking/src/udt/Socket.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 0eda2ee2e0..deed00ac4b 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -446,7 +446,11 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiS return size; } else { - return sendUnreliablePacket(*packet, sockAddr, hmacAuth); + auto size = sendUnreliablePacket(*packet, sockAddr, hmacAuth); + if (size < 0) { + + } + return size; } } diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 5e68070bb7..5dab1ad2b5 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -226,8 +226,11 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc qint64 bytesWritten = _udpSocket.writeDatagram(datagram, sockAddr.getAddress(), sockAddr.getPort()); if (bytesWritten < 0) { - // when saturating a link this isn't an uncommon message - suppress it so it doesn't bomb the debug - qCDebug(networking) << "Socket::writeDatagram : " << sockAddr << " " << _udpSocket.error(); + qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << _udpSocket.error() << "(" << _udpSocket.errorString() << ")"; +#ifdef DEBUG_EVENT_QUEUE + int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread()); + qCDebug(networking) << "Networking queue size - " << nodeListQueueSize; +#endif // DEBUG_EVENT_QUEUE } return bytesWritten; From 04f879be3e70ff2a911c6cdd895a3c56d5fe070a Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Wed, 5 Jun 2019 12:41:08 -0700 Subject: [PATCH 3/4] Add additional logging on socket send error --- libraries/networking/src/LimitedNodeList.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 13ebf7f9f6..48f08d6d2e 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -439,7 +439,14 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiS } else { auto size = sendUnreliablePacket(*packet, sockAddr, hmacAuth); if (size < 0) { - + auto now = usecTimestampNow(); + eachNode([now](const SharedNodePointer & node) { + qCDebug(networking) << "Stats for " << node->getPublicSocket() << "\n" + << " Last Heard Microstamp: " << node->getLastHeardMicrostamp() << " (" << (now - node->getLastHeardMicrostamp()) << "usec ago)\n" + << " Outbound Kbps: " << node->getOutboundKbps() << "\n" + << " Inbound Kbps: " << node->getInboundKbps() << "\n" + << " Ping: " << node->getPingMs(); + }); } return size; } From 2f2e967a923cbacc25b8e484dbb02aa636fd3f9a Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Wed, 5 Jun 2019 14:08:26 -0700 Subject: [PATCH 4/4] log windows socket error code on socket error --- libraries/networking/src/udt/Socket.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index bec651a98b..2867e83a1c 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -227,6 +227,12 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc if (bytesWritten < 0) { qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << _udpSocket.error() << "(" << _udpSocket.errorString() << ")"; + +#ifdef WIN32 + int wsaError = WSAGetLastError(); + qCDebug(networking) << "windows socket error " << wsaError; +#endif + #ifdef DEBUG_EVENT_QUEUE int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread()); qCDebug(networking) << "Networking queue size - " << nodeListQueueSize;