Huge number of socket notification on message dataUpdated


After subscribing with
liveCollection.on(‘dataUpdated’, data => {messages = data;});

like in the doc exemple,
It begins with 5 dataUpdated notification for the first message then
I’m receiving up to 300 socket notifications for one single message received, the amount of notification grows indefinitly for only 2 users in the channel


Hi @guid could you please share your code snippet when using this function?


Here is the sample:


if (!this.client) {
            this.client = new AmityClient({ apiKey, apiRegion: ApiRegion.EU });

this.client.registerSession({ userId:, displayName: `${this.currentUser.firstName} ${this.currentUser.lastName}` });


private getChatUser() {
        try {
            this.liveUser = UserRepository.getUser(;
            this.liveUser.once('dataUpdated', model => { this.onUserUpdated(model); });
            this.liveUser.once('dataError', error => { this.onUserError(error); });
        } catch (error) {

private listChannels() {
        for (let channelConfig of this.channelConfigList) {

            let channelId = channelConfig.getChannelId();
            let channel = ChannelRepository.getChannel(channelId);

            if (channel && channel.dataStatus !== CHAT_CHANNEL_NOT_EXISTS) {
                this.addChannel(channel.model, channelConfig);
                channel.on('dataUpdated', channelUpdated => { this.onChannelUpdated(channelConfig, channelUpdated) });
                channel.once('dataError', error => { this.onChannelError(channelId, error) });
            } else {
                this.addChannel(null, channelConfig);

private onChannelUpdated(channelConfig: ChatChannelConfig, _channel: any) {
        // console.log(`[AmityService.onChannelUpdated]`, channelConfig.getChannelId());
        let chatChannel = this.addChannel(_channel, channelConfig);

        if (!chatChannel.messageLoaded) {
            // Lister les messages du channel
            this.listChannelMembers(channelConfig, _channel);
        // this.chatChannelList$.next(this.chatChannelList);

private listChannelMessage(channelId) {
        let messageList = MessageRepository.queryMessages({ channelId });
        messageList.on('dataUpdated', messageList => this.onChannelMessageListUpdated(channelId, messageList));
        messageList.on('dataError', messageList => this.onChannelMessageListError(channelId, messageList));

private onChannelMessageListUpdated(channelId: string, messageList) {
        console.log(`[AmityService.onChannelMessageListUpdated]`, channelId);
        const channel = this.getChatChannelById(channelId);
        if ((channel.messageList || []).length != messageList.length) {

Once receiving a message, handler onChannelMessageListUpdated is called 5 times for the first message, on the second, i’m getting around 9 call of this handler et it keeps growing.

Thanks for your help.

My answer has been hidden by Akismeet.
Hope you can see it.

@guid Yes, I can see your post.
Thank you.

If you need the entire js files, I can send them by mail if you want.

@guid Can you sand email us at ?
Thank you :grinning: .

files sent with explanations.


1 Like

@guid I have received the files and I will pass this to the team for further investigation.

@guid Can you try to change from channel.on(‘dataUpdated’, …
to channel.once(‘dataUpdated’,… ?

We use to have channel.once(‘dataUpdated’,… until yesterday.
the problem of receiving multiple call on messageList.on(‘dataUpdated’,…) Handler was already present.

Do you have the same issue ?

Hi, @guid Can I have more information?​

  1. How many channels does the user join?
  2. The object that your receive is it all the same?

Here is a video to see what’s happening in details

I started from scratch a new implementation to ensure i add not mistakes
the code is directly on the web page.

Video of the result: Loom | Free Screen & Video Recording Software

Code ( use of liveChannel.once instead of .on):

apiKey = environment.AmityApiKey;
channelId = 'lpmember<11180>_orga<2>';
messageListLoaded = false;

loadSampleAmity() {

  this.client = new AmityClient({ apiKey: this.apiKey, apiRegion: ApiRegion.EU });

  this.client.userId =;

  let sessionData = {
    displayName: `${this.currentUser.fullIdentity.firstName} ${this.currentUser.fullIdentity.lastName}`

  // Get User Data
  const liveUser = UserRepository.getUser(;
  liveUser.once('dataUpdated', model => {
    console.log(`[getUser.dataUpdated]`, model);

    // const channelId = 'lpmember<11180>_orga<2>';
    let liveChannel = ChannelRepository.getChannel(this.channelId);
    if (liveChannel.dataStatus == 'not-exist') {
      console.error(`channel ${this.channelId} does not exists -> exit`);

    liveChannel.once('dataError', error => { console.error(`[getChannel.dataError]`, error) });
    liveChannel.once('dataUpdated', channelUpdated => {
      this.singleChannel = channelUpdated;
      console.log(`channel ${this.channelId} updated`);

      if (this.messageListLoaded)
        return; // Exit if already loaded

      console.log(`Load messages for channel ${this.channelId}`);
      this.messageListLoaded = true;
      let queryMessagesData = { channelId: this.channelId };
      let messageList = MessageRepository.queryMessages(queryMessagesData);
      messageList.on('dataError', error => {
        console.error(`[queryMessages.dataError]`, error)

      messageList.on('dataUpdated', messageList => {
        console.log(`[queryMessages.dataUpdated( messageList.length = ${messageList.length})]`);



  liveUser.once('dataError', error => {
    console.error(`[getUser.dataError]`, error);

postMessage() {
  let data = {
    channelId: this.channelId,
    text: new Date().getTime().toString()

Hi @guid our team is investigating this issue, I will keep you posted on the progress, thank you :pray:

Hi @guid is this issue still persisting? Our team has checked and seems that it’s solved :pray: Please let us know if it’s still happening.