From c2f3607d0393a378c3b558d22fbfd7cb4bac0fe2 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Tue, 15 Feb 2022 04:55:21 -0800 Subject: [PATCH] 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 --- .../flipper/android/FlipperProps.java | 4 +-- iOS/FlipperKit/FlipperClient.mm | 8 ++--- iOS/FlipperKit/SKEnvironmentVariables.m | 4 +-- .../Flipper/FlipperConnectionManagerImpl.cpp | 31 ++----------------- xplat/Flipper/FlipperConnectionManagerImpl.h | 2 -- xplat/Flipper/FlipperInitConfig.h | 4 +-- 6 files changed, 12 insertions(+), 41 deletions(-) diff --git a/android/src/main/java/com/facebook/flipper/android/FlipperProps.java b/android/src/main/java/com/facebook/flipper/android/FlipperProps.java index cb2e1293a..0d8647ae3 100644 --- a/android/src/main/java/com/facebook/flipper/android/FlipperProps.java +++ b/android/src/main/java/com/facebook/flipper/android/FlipperProps.java @@ -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"; diff --git a/iOS/FlipperKit/FlipperClient.mm b/iOS/FlipperKit/FlipperClient.mm index 1da8c2c9b..948a90902 100644 --- a/iOS/FlipperKit/FlipperClient.mm +++ b/iOS/FlipperKit/FlipperClient.mm @@ -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(); } diff --git a/iOS/FlipperKit/SKEnvironmentVariables.m b/iOS/FlipperKit/SKEnvironmentVariables.m index 8337f808a..312a778a1 100644 --- a/iOS/FlipperKit/SKEnvironmentVariables.m +++ b/iOS/FlipperKit/SKEnvironmentVariables.m @@ -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; diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.cpp b/xplat/Flipper/FlipperConnectionManagerImpl.cpp index f79b7fe6e..7258a9391 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.cpp +++ b/xplat/Flipper/FlipperConnectionManagerImpl.cpp @@ -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(); } diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.h b/xplat/Flipper/FlipperConnectionManagerImpl.h index 1bad5cac0..4d95ae199 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.h +++ b/xplat/Flipper/FlipperConnectionManagerImpl.h @@ -75,8 +75,6 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager { int failedConnectionAttempts_ = 0; int failedSocketConnectionAttempts = 0; - bool useLegacySocketProvider = false; - std::shared_ptr contextStore_; std::shared_ptr implWrapper_; diff --git a/xplat/Flipper/FlipperInitConfig.h b/xplat/Flipper/FlipperInitConfig.h index a3002bde5..252318c19 100644 --- a/xplat/Flipper/FlipperInitConfig.h +++ b/xplat/Flipper/FlipperInitConfig.h @@ -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; };