Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix issue where emulator connects to the wrong host upon reconnect #5903

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maneesht
Copy link
Contributor

@maneesht maneesht commented Apr 24, 2024

When the handshake with the WebSocket is complete, the server responds with the host name and port, which we then use upon reconnection.

When using the firebase emulator, the server defaults to the host and port mentioned in the firebase.json, but if the user is using a different host name to connect to the firebase emulator (such as 10.0.2.2 when the Android Emulator talks to the host machine's server), we end up caching the host name in firebase.json and end up reconnecting to the wrong host name and port.

This PR attempts to introduce state called isUsingEmulator to prevent caching of the hostname, and therefore connecting to the default host name provided by the user's config.

Fixes #5870

Copy link
Contributor

github-actions bot commented Apr 24, 2024

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@maneesht maneesht marked this pull request as draft April 24, 2024 18:42
@google-oss-bot
Copy link
Contributor

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

@google-oss-bot
Copy link
Contributor

Coverage Report 1

Affected Products

  • firebase-database

    Overall coverage changed from ? (68fb692) to 50.17% (d90430e) by ?.

    159 individual files with coverage change

    FilenameBase (68fb692)Merge (d90430e)Diff
    AckUserWrite.java?88.89%?
    AndroidAppCheckTokenProvider.java?50.00%?
    AndroidAuthTokenProvider.java?42.31%?
    AndroidEventTarget.java?42.86%?
    AndroidLogger.java?45.45%?
    AndroidPlatform.java?40.48%?
    BooleanNode.java?100.00%?
    CacheNode.java?100.00%?
    CachePolicy.java?50.00%?
    CancelEvent.java?0.00%?
    Change.java?91.67%?
    ChildChangeAccumulator.java?96.67%?
    ChildEvent.kt?0.00%?
    ChildEventListener.java?0.00%?
    ChildEventRegistration.java?0.00%?
    ChildKey.java?90.00%?
    ChildrenNode.java?73.40%?
    Clock.java?0.00%?
    CompoundHash.java?0.00%?
    CompoundWrite.java?87.85%?
    Connection.java?27.97%?
    ConnectionContext.java?90.00%?
    ConnectionTokenProvider.java?0.00%?
    ConnectionUtils.java?7.14%?
    Constants.java?0.00%?
    Context.java?77.39%?
    CustomClassMapper.java?88.52%?
    Database.kt?20.00%?
    DatabaseConfig.java?62.00%?
    DatabaseError.java?0.00%?
    DatabaseException.java?50.00%?
    DatabaseReference.java?23.36%?
    DatabaseRegistrar.java?100.00%?
    DataEvent.java?70.00%?
    DataSnapshot.java?67.57%?
    DefaultClock.java?100.00%?
    DefaultLogger.java?66.67%?
    DefaultPersistenceManager.java?74.76%?
    DefaultRunLoop.java?57.14%?
    DeferredValueNode.java?0.00%?
    DoubleNode.java?100.00%?
    Emitters.kt?0.00%?
    EmptyNode.java?83.33%?
    Event.java?100.00%?
    EventGenerator.java?100.00%?
    EventRaiser.java?25.00%?
    EventRegistration.java?41.18%?
    EventRegistrationZombieListener.java?0.00%?
    EventTarget.java?0.00%?
    Exclude.java?0.00%?
    FirebaseDatabase.java?37.21%?
    FirebaseDatabaseComponent.java?100.00%?
    GAuthToken.java?81.82%?
    GenericTypeIndicator.java?100.00%?
    HostInfo.java?85.71%?
    IgnoreExtraProperties.java?0.00%?
    ImmutableTree.java?84.52%?
    Index.java?53.33%?
    IndexedFilter.java?93.62%?
    IndexedNode.java?95.71%?
    InternalHelpers.java?60.00%?
    JsonMapper.java?59.32%?
    KeyIndex.java?81.82%?
    LeafNode.java?91.55%?
    LimitedFilter.java?97.67%?
    ListenComplete.java?0.00%?
    ListenHashProvider.java?0.00%?
    Logger.java?100.00%?
    LogWrapper.java?71.43%?
    LongNode.java?93.75%?
    LRUCachePolicy.java?0.00%?
    Merge.java?81.25%?
    MessageBuilderFactory.java?0.00%?
    MutableData.java?76.00%?
    NameAndPriority.java?0.00%?
    NamedNode.java?66.67%?
    Node.java?50.00%?
    NodeAndPath.java?0.00%?
    NodeFilter.java?0.00%?
    NodeSizeEstimator.java?0.00%?
    NodeUtilities.java?87.93%?
    NoopPersistenceManager.java?77.50%?
    NotNull.java?0.00%?
    Nullable.java?0.00%?
    OffsetClock.java?75.00%?
    OnDisconnect.java?0.00%?
    Operation.java?100.00%?
    OperationSource.java?94.12%?
    Overwrite.java?80.00%?
    Pair.java?30.00%?
    ParsedUrl.java?66.67%?
    Path.java?87.12%?
    PathAndId.java?0.00%?
    PathIndex.java?92.31%?
    PersistenceManager.java?0.00%?
    PersistenceStorageEngine.java?0.00%?
    PersistentConnection.java?0.00%?
    PersistentConnectionImpl.java?17.18%?
    Platform.java?0.00%?
    Predicate.java?100.00%?
    PriorityIndex.java?83.33%?
    PriorityUtilities.java?76.92%?
    PropertyName.java?0.00%?
    PruneForest.java?76.06%?
    PushIdGenerator.java?84.13%?
    Query.java?44.22%?
    QueryParams.java?89.76%?
    QuerySpec.java?88.46%?
    RangedFilter.java?100.00%?
    RangeMerge.java?0.00%?
    Repo.java?10.31%?
    RepoInfo.java?71.88%?
    RepoManager.java?32.88%?
    RequestResultCallback.java?0.00%?
    RetryHelper.java?74.19%?
    RunLoop.java?0.00%?
    SafeCollector.common.kt?0.00%?
    ServerValue.java?0.00%?
    ServerValues.java?50.00%?
    SnapshotHolder.java?100.00%?
    SparseSnapshotTree.java?17.86%?
    SqlPersistenceStorageEngine.java?0.00%?
    StringListReader.java?0.00%?
    StringNode.java?87.50%?
    SyncPoint.java?88.89%?
    SyncTree.java?56.89%?
    Tag.java?71.43%?
    ThreadBackgroundExecutor.java?0.00%?
    ThreadInitializer.java?100.00%?
    ThreadPoolEventTarget.java?0.00%?
    ThrowOnExtraProperties.java?0.00%?
    TokenProvider.java?0.00%?
    TrackedQuery.java?46.15%?
    TrackedQueryManager.java?99.45%?
    Transaction.java?0.00%?
    Tree.java?50.00%?
    TreeNode.java?25.00%?
    UserWriteRecord.java?57.14%?
    Utilities.java?68.99%?
    Validation.java?42.67%?
    ValidationPath.java?95.65%?
    ValueEventListener.java?0.00%?
    ValueEventRegistration.java?0.00%?
    ValueIndex.java?0.00%?
    ValueProvider.java?50.00%?
    View.java?85.11%?
    ViewCache.java?100.00%?
    ViewProcessor.java?92.10%?
    WebSocket.java?37.50%?
    WebsocketConnection.java?32.77%?
    WebSocketEventHandler.java?0.00%?
    WebSocketException.java?50.00%?
    WebSocketHandshake.java?26.67%?
    WebSocketMessage.java?0.00%?
    WebSocketReceiver.java?12.82%?
    WebSocketWriter.java?19.23%?
    WriteTree.java?76.67%?
    WriteTreeRef.java?100.00%?
    ZombieEventManager.java?0.00%?

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/ZU2Jlfxwcq.html

Copy link
Contributor

Unit Test Results

  70 files   -    880    70 suites   - 880   1m 8s ⏱️ - 34m 9s
416 tests  - 4 800  414 ✔️  - 4 780  2 💤  - 20  0 ±0 
858 runs   - 9 659  854 ✔️  - 9 619  4 💤  - 40  0 ±0 

Results for commit d455a90. ± Comparison against base commit 68fb692.

@google-oss-bot
Copy link
Contributor

@google-oss-bot
Copy link
Contributor

Startup Time Report 1

Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS.

Startup time comparison between the CI merge commit (d90430e) and the base commit (68fb692) are not available.

No macrobenchmark data found for the base commit (68fb692). Analysis for the CI merge commit (d90430e) can be found at:

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/V4aE2uWBih/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FirebaseDatabase.GoOnline does not work when connecting to a Firebase Emulator on Android Emulators
2 participants