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

Message's listen not working on new created subscription in flutter web environment #70

Open
sohyuyuan opened this issue Oct 18, 2021 · 1 comment
Assignees
Labels
status: waiting This issue waits for feedback from author. type: bug This issue reports a bug.

Comments

@sohyuyuan
Copy link

sohyuyuan commented Oct 18, 2021

Pubnub Dart SDK version: ^4.0.0-beta.0
Dart SDK version: 2.14.3
Fltuter version: Flutter 2.5.2

Works fine in mobile applications.
Mobile application output:

I/flutter (26388): Message no. 1
I/flutter (26388): Message no. 2
I/flutter (26388): Message no. 3
I/flutter (26388): Message no. 4
I/flutter (26388): Message no. 5
I/flutter (26388): Message no. 10
I/flutter (26388): Message no. 11
I/flutter (26388): Message no. 12
I/flutter (26388): Message no. 13
I/flutter (26388): Message no. 14
I/flutter (26388): Message no. 15

The issue occurs at flutter web.
Flutter web console output :

I/flutter (26388): Message no. 1
I/flutter (26388): Message no. 2
I/flutter (26388): Message no. 3
I/flutter (26388): Message no. 4
I/flutter (26388): Message no. 5

Code:

Future<void> testPubNub() async {
    var pubnub = PubNub(
        defaultKeyset: Keyset(
            subscribeKey: 'subKey',
            publishKey: 'pubKey',
            uuid: UUID('uniqueId')));

    // Subscribe to a channel
    var channel = "getting_started";

    var subscription = pubnub.subscribe(channels: {channel});
    subscription.messages.listen((message) {
      print(message.content);
    });

    // Send a message every second for 5 seconds
    for (var i = 1; i <= 5; i++) {
      await pubnub.publish(channel, 'Message no. $i');
      await Future.delayed(const Duration(seconds: 1));
    }

    // Unsubscribe and quit
    await subscription.cancel();

    var channel2 = "getting_started2";

    var subscription2 = pubnub.subscribe(channels: {channel2});
    subscription2.messages.listen((message) {
      print(message.content);
    });

    // Send a message every second for 5 seconds
    for (var i = 10; i <= 15; i++) {
      await pubnub.publish(channel2, 'Message no. $i');
      await Future.delayed(const Duration(seconds: 1));
    }

    // Unsubscribe and quit
    await subscription2.cancel();
  }

Update:
The above issue is happening in local debugging.
After building the webpack and using http-server to serve it at local, it's working fine.

@are
Copy link
Contributor

are commented Oct 18, 2021

Hello! Thanks for reporting your issue!

Could you please enable logging as described here and send the logs to our PubNub Support? This way we can troubleshoot this faster and avoid leaking your private information. Thanks!

@are are self-assigned this Oct 18, 2021
@are are added status: waiting This issue waits for feedback from author. type: bug This issue reports a bug. labels Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting This issue waits for feedback from author. type: bug This issue reports a bug.
Projects
None yet
Development

No branches or pull requests

2 participants