Skip to content

Subscribing to multiple streams concurrently doesn't work #242

@RobertOdrowaz

Description

@RobertOdrowaz

Describe the bug
When subscribing (starting the subscription) to 2 streams at the same time ie.

await Future.wait(
  [
    client.flatFeed(slug, userId).subscribe((message) {}),
    client.flatFeed(slug2, userId).subscribe((message) {}),
  ],
);

the Futures either never complete or throw FayeClientError (null : : Client not found, please reconnect.). Subscribing sequentially ie.

await client.flatFeed(slug, userId).subscribe((message) {});
await client.flatFeed(slug2, userId).subscribe((message) {});

works fine.

What version of Flutter do you use?
Flutter 3.3.8 • channel stable

What package are you using? What version?
stream_feed: ^0.6.0+2

What platform is it about?

  • Android
  • iOS
  • Web
  • Windows
  • MacOS
  • Linux

a copy of flutter doctor --verbose

[✓] Flutter (Channel stable, 3.3.8, on macOS 12.5 21G72 darwin-arm, locale en-PL)
    • Flutter version 3.3.8 on channel stable at /Users/robert/fvm/versions/3.3.8
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (9 weeks ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/robert/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/robert/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • D574B9B8-57D2-4905-ACD5-49816DE8DC58 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 12.5 21G72 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

To Reproduce
Steps to reproduce the behavior:

  1. Add test code:
void main() async {
  test(
    'FayeClient',
    () async {
      const appId = '';
      const apiKey = '';
      const secret = '';
      const userId = '';
      const slug = '';
      const slug2 = '';

      final client = StreamFeedClient(
        apiKey,
        secret: secret,
        appId: appId,
        runner: Runner.server,
      );

      // Either never ends or throws "FayeClientError (null :  : Client not found, please reconnect.)" exception
      await Future.wait(
        [
          client.flatFeed(slug, userId).subscribe((message) {}),
          client.flatFeed(slug2, userId).subscribe((message) {}),
        ],
      );

      // Subscribing sequentially works fine
      // await client.flatFeed(slug, userId).subscribe((message) {});
      // await client.flatFeed(slug2, userId).subscribe((message) {});
    },
  );
}
  1. Enter project variables
  2. Run test

Expected behavior
Not exception is thrown and futures do finish

Screenshots
image

**Logs **
Run flutter analyze and attach any output of that command below.
If there are any analysis errors, try resolving them before filing this issue.

Analyzing realtime_test.dart...                                         
No issues found! (ran in 1.2s)

Paste the output of running flutter doctor -v here.

[✓] Flutter (Channel stable, 3.3.8, on macOS 12.5 21G72 darwin-arm, locale en-PL)
    • Flutter version 3.3.8 on channel stable at /Users/robert/fvm/versions/3.3.8
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (9 weeks ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/robert/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/robert/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • D574B9B8-57D2-4905-ACD5-49816DE8DC58 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 12.5 21G72 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions