Open
Description
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.