remove rsocket fallback for mobile clients

Summary:
^
Note: this is already a working case. The difference is that if we are unable to establish a socket connection, we will not attempt to create one using rsocket.

Changelog: Removes rsocket-fallback for mobile clients

Reviewed By: nikoant

Differential Revision: D33655430

fbshipit-source-id: cb6f752f2d1354ab46d011b1f19c89520e1e7dd3
This commit is contained in:
Lorenzo Blasa
2022-02-15 04:55:21 -08:00
committed by Facebook GitHub Bot
parent e602cc0305
commit c2f3607d03
6 changed files with 12 additions and 41 deletions

View File

@@ -17,8 +17,8 @@ class FlipperProps {
private static final String FLIPPER_PORTS_PROP_NAME = "flipper.ports";
private static final String FLIPPER_ALT_PORTS_PROP_NAME = "flipper.alt.ports";
private static final int DEFAULT_INSECURE_PORT = 8089;
private static final int DEFAULT_SECURE_PORT = 8088;
private static final int DEFAULT_INSECURE_PORT = 9089;
private static final int DEFAULT_SECURE_PORT = 9088;
private static final int DEFAULT_ALT_INSECURE_PORT = 9089;
private static final int DEFAULT_ALT_SECURE_PORT = 9088;
private static final String TAG = "Flipper";

View File

@@ -154,11 +154,11 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
- (void)start {
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
_secureServer = [FKPortForwardingServer new];
[_secureServer forwardConnectionsFromPort:8088];
[_secureServer listenForMultiplexingChannelOnPort:8078];
[_secureServer forwardConnectionsFromPort:9088];
[_secureServer listenForMultiplexingChannelOnPort:9078];
_insecureServer = [FKPortForwardingServer new];
[_insecureServer forwardConnectionsFromPort:8089];
[_insecureServer listenForMultiplexingChannelOnPort:8079];
[_insecureServer forwardConnectionsFromPort:9089];
[_insecureServer listenForMultiplexingChannelOnPort:9079];
#endif
_cppClient->start();
}

View File

@@ -9,8 +9,8 @@
#import "SKEnvironmentVariables.h"
static int const DEFAULT_INSECURE_PORT = 8089;
static int const DEFAULT_SECURE_PORT = 8088;
static int const DEFAULT_INSECURE_PORT = 9089;
static int const DEFAULT_SECURE_PORT = 9088;
static int const DEFAULT_ALT_INSECURE_PORT = 9089;
static int const DEFAULT_ALT_SECURE_PORT = 9088;

View File

@@ -31,8 +31,6 @@ static constexpr int reconnectIntervalSeconds = 2;
// To be bumped for every core platform interface change.
static constexpr int sdkVersion = 4;
static constexpr int maxFailedSocketConnectionAttempts = 3;
using namespace folly;
namespace facebook {
@@ -79,7 +77,6 @@ class ConnectionEvents {
impl->connectionIsTrusted_ = false;
impl->callbacks_->onDisconnected();
}
impl->reevaluateSocketProvider();
impl->reconnect();
break;
}
@@ -199,7 +196,7 @@ void FlipperConnectionManagerImpl::startSync() {
}
bool FlipperConnectionManagerImpl::connectAndExchangeCertificate() {
auto port = useLegacySocketProvider ? insecurePort : altInsecurePort;
auto port = insecurePort;
auto endpoint = FlipperConnectionEndpoint(deviceData_.host, port, false);
int medium = certProvider_ != nullptr
@@ -222,7 +219,6 @@ bool FlipperConnectionManagerImpl::connectAndExchangeCertificate() {
connectionIsTrusted_ = false;
if (!newClient->connect(this)) {
reevaluateSocketProvider();
connectingInsecurely->fail("Failed to connect");
return false;
}
@@ -241,7 +237,7 @@ bool FlipperConnectionManagerImpl::connectAndExchangeCertificate() {
bool FlipperConnectionManagerImpl::connectSecurely() {
client_ = nullptr;
auto port = useLegacySocketProvider ? securePort : altSecurePort;
auto port = securePort;
auto endpoint = FlipperConnectionEndpoint(deviceData_.host, port, true);
int medium = certProvider_ != nullptr
@@ -289,7 +285,6 @@ bool FlipperConnectionManagerImpl::connectSecurely() {
connectionIsTrusted_ = true;
if (!newClient->connect(this)) {
reevaluateSocketProvider();
connectingSecurely->fail("Failed to connect");
return false;
}
@@ -467,28 +462,6 @@ void FlipperConnectionManagerImpl::requestSignedCertFromFlipper() {
failedConnectionAttempts_ = 0;
}
/**
Check for the maximum number of failed socket connection attempts.
If exceeded, then swap the default socket provider. If the maximum
number of failed attempts is reached again, swap again the socket provider.
WebSocket -> RSocket -> WebSocket -> ...
*/
void FlipperConnectionManagerImpl::reevaluateSocketProvider() {
if (failedSocketConnectionAttempts < maxFailedSocketConnectionAttempts) {
++failedSocketConnectionAttempts;
} else {
failedSocketConnectionAttempts = 0;
useLegacySocketProvider = !useLegacySocketProvider;
if (useLegacySocketProvider) {
FlipperSocketProvider::shelveDefault();
} else {
FlipperSocketProvider::unshelveDefault();
}
}
}
bool FlipperConnectionManagerImpl::isRunningInOwnThread() {
return flipperEventBase_->isInEventBaseThread();
}

View File

@@ -75,8 +75,6 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager {
int failedConnectionAttempts_ = 0;
int failedSocketConnectionAttempts = 0;
bool useLegacySocketProvider = false;
std::shared_ptr<ConnectionContextStore> contextStore_;
std::shared_ptr<FlipperConnectionManagerWrapper> implWrapper_;

View File

@@ -39,8 +39,8 @@ struct FlipperInitConfig {
*/
folly::EventBase* connectionWorker;
int insecurePort = 8089;
int securePort = 8088;
int insecurePort = 9089;
int securePort = 9088;
int altInsecurePort = 9089;
int altSecurePort = 9088;
};