diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 0b0dde106..8ee31fb5a 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "CertificateUtils.h" #ifdef __ANDROID__ @@ -116,14 +117,25 @@ void SonarWebSocketImpl::startSync() { SONAR_LOG("Already connected"); return; } + auto connect = sonarState_->start("Connect to desktop"); try { if (isCertificateExchangeNeeded()) { doCertificateExchange(); return; } - connectSecurely(); - } catch (const std::exception&) { + + connect->complete(); + } catch (const folly::AsyncSocketException& e) { + if (e.getType() == folly::AsyncSocketException::NOT_OPEN) { + // The expected code path when flipper desktop is not running. + } else { + SONAR_LOG(e.what()); + failedConnectionAttempts_++; + } + reconnect(); + } catch (const std::exception& e) { + SONAR_LOG(e.what()); failedConnectionAttempts_++; reconnect(); }