Handle socket not open error individually
Summary: It's expected that whenever not connected to a desktop, or when the sonar desktop app isn't running, we'll get errors connecting. Isolate these so we can treat all other exceptions properly. Reviewed By: passy Differential Revision: D9333323 fbshipit-source-id: c9853ca84d1a04827ebf7bae0fe87859ca6110d1
This commit is contained in:
committed by
Facebook Github Bot
parent
292cb4107b
commit
dfcfa9f7fa
@@ -20,6 +20,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <folly/io/async/AsyncSocketException.h>
|
||||||
#include "CertificateUtils.h"
|
#include "CertificateUtils.h"
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
@@ -116,14 +117,25 @@ void SonarWebSocketImpl::startSync() {
|
|||||||
SONAR_LOG("Already connected");
|
SONAR_LOG("Already connected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto connect = sonarState_->start("Connect to desktop");
|
||||||
try {
|
try {
|
||||||
if (isCertificateExchangeNeeded()) {
|
if (isCertificateExchangeNeeded()) {
|
||||||
doCertificateExchange();
|
doCertificateExchange();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectSecurely();
|
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_++;
|
failedConnectionAttempts_++;
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user