No data on getStreamController().stream

I use way to fetch messages:

  observeMessages(String channelId) {
    final collection = AmityChatClient.newMessageRepository()
        .getMessages(channelId)
        .getLiveCollection();
    collection.loadNext();
    collection.getStreamController().stream.listen(
      (messages) {
        print(messages);
      },
      onError: (e) {
        print(e);
      },
    );
  }

I know there is some messages present, but they are not coming on listen stream until I send a new message or until I make hot reload

please resolve or give answer ASAP

tested on IOS 18.5

flutter version : 3.32.1
amity_sdk: 7.4.6

Hello @Yarshau, we’ve shared the details with our team for further review and will get back to you as soon as we have any updates. Thank you.

Hello @Yarshau , Just a quick check — are you using the EU region for your Amity setup?

If so, could you please share how you’re initializing AmityCoreClient.setup()? If you’re using this format:

await AmityCoreClient.setup(
  option: AmityCoreClientOption.create(
    apiKey: 'apiKey',
    endpoint: AmityEndpoint.EU,
  ),
  sycInitialization: true,
);

We recommend switching to this format instead:

await AmityCoreClient.setup(
  option: AmityCoreClientOption(
    apiKey: 'apiKey',
    httpEndpoint: AmityRegionalHttpEndpoint.EU,
    mqttEndpoint: AmityRegionalMqttEndpoint.EU,
  ),
  sycInitialization: true,
);

This version ensures proper MQTT subscription behavior, especially in EU or SG regions.


Also, regarding the issue where messages don’t appear in the stream until a new one is sent or you hot reload — please try modifying your message fetching code like this:

observeMessages(String channelId) {
  final collection = AmityChatClient.newMessageRepository()
      .getMessages(channelId)
      .stackFromEnd(true)
      .includingTags([])
      .excludingTags([])
      .includeDeleted(true)
      .filterByParent(false)
      .getLiveCollection();

  collection.loadNext();

  collection.getStreamController().stream.listen(
    (messages) {
      print(messages);
    },
    onError: (e) {
      print(e);
    },
  );
}

This setup helps ensure that LiveCollection starts streaming messages reliably, even without triggering events like sending a new message.

Let us know if the issue persists — happy to help further!

Yes, I am using EU region should I change it?

your comment was not helpful

here is my initialization:

  Future<void> initAmity(User? user) async {
    try {
      await AmityCoreClient.setup(
        sycInitialization: true,
        option: AmityCoreClientOption(
          apiKey: appConfig.amityApiKey,
          httpEndpoint: AmityRegionalHttpEndpoint.EU,
          mqttEndpoint: AmityRegionalMqttEndpoint.EU,
        ),
      );

      _loginUser(user);
    } on AmityException catch (e) {
      log('AmityException ${e.message}');
    } catch (e) {
      log('AmityError $e');
    }
  }

message fetching code:

observeMessages(String channelId) {
  final collection = AmityChatClient.newMessageRepository()
      .getMessages(channelId)
      .stackFromEnd(true)
      .includingTags([])
      .excludingTags([])
      .includeDeleted(true)
      .filterByParent(false)
      .getLiveCollection();

  collection.loadNext();

  collection.getStreamController().stream.listen(
    (messages) {
      print(messages);
    },
    onError: (e) {
      print(e);
    },
  );
}

before fetched messages I also fetching communities, they works fine, here is how I do it:

  Stream<List<AmityCommunity>> queryCommunitiesStream(
    AmityCommunitySortOption sortOption,
    AmityCommunityFilter filter,
  ) {
    final CommunityLiveCollection liveCollection =
        AmitySocialClient.newCommunityRepository()
            .getCommunities()
            .filter(filter)
            .sortBy(sortOption)
            .includeDeleted(true)
            .getLiveCollection();

    liveCollection.loadNext();
    return liveCollection.getStreamController().stream;
  }

Also on send message I receive Error on try catch block - Message feed not found, here is code sample:

  Future<void> sendMessage(String channelId, String text) async {
    try {
      await AmityChatClient.newChannelRepository().joinChannel(channelId);

      final message = await AmityChatClient.newMessageRepository()
          .createMessage(channelId)
          .text(text)
          .send();
      log("Message sent: ${message.messageId}");
    } catch (e) {
      log("sendMessage Error: $e");
    }
  }

On trying addMessageReaction - Unhandled Exception: Parameters validation error!, here is code sample:

  void addMessageReaction(AmityMessage message) {
    message
        .react()
        .addReaction('like')
        .then((value) => {log('value reacted ${value}')});
  }

So, I suppose there is a bug on your side with initial fetching messages, sending messages, and sending reactions at least.
Please resolve them.

1 Like

Hello @Yarshau , Thanks for sharing the detailed code and context.

I’ll pass this along to our technical team to investigate further — particularly the issues you’re seeing with:

  • Initial message fetching not working as expected
  • “Message feed not found” error on sendMessage
  • Parameter validation error when calling addMessageReaction

Also noted that you’re using the EU region with the recommended httpEndpoint and mqttEndpoint setup, and that community fetching works fine — that helps narrow things down.

We’ll follow up once the team has reviewed and can provide next steps or fixes.

Hello @Yarshau , Our team would like to confirm whether you’re using only the Amity SDK version 7.4.6, and not using our open-source UIKit.

We’ve attempted to reproduce the issue using our sample project, but have been unable to replicate the behavior so far. This information will help us narrow down the root cause more effectively.