Messages not updated even already subscribed subchannel

I have implemented live chat application as web app. I using getMessages function from sdk to get the collection of messages. I also create code to subscribed the subchannel to get an updated collection of message but messages seem not updated. The callback function is not even trigger when new message was send by other devices. The messages will be updated only when refresh the page or send the new message (message will be updated only in its application).

here is my code

useEffect(() => {
    if (isJoinedChannel && subChannel) {
      const unsubscribe = MessageRepository.getMessages(
        { subChannelId: subChannel.subChannelId, limit: 100 },
        ({ data: messages, onNextPage, hasNextPage, loading, error }) => {
          console.log('Callback triggered:', { messages, loading, error })
          if (error) {
            logger.error('Messages Error:', error)
            return
          }
          if (loading) {
            logger.info('Messages Loading...')
            return
          }
          if (messages) {
            logger.success('Messages Received:', messages)
            if (messages.length > 0) {
              setMessages(messages)
            }
            subscribeSubChannelTopic()
          }
        }
      )

      disposers.push(unsubscribe)

      return () => {
        disposers.forEach((fn) => fn())
      }
    }
  }, [isJoinedChannel, subChannel])

const subscribeSubChannelTopic = async () => {
    if (subChannel) {
      const unsubscribe = subscribeTopic(getSubChannelTopic(subChannel))
      console.log('Subscribed to SubChannel Topic', unsubscribe)
      disposers.push(unsubscribe)
    }
  }

sdk: @amityco/ts-sdk (6.33.1)
framework: nextjs (15.1.4)

Not sure if I did something wrong?

Hello @new.suppawit , thank you for providing all the information. We have forwarded it to our team, and we’ll keep you updated on any progress.

1 Like

Seems like it will not working only in SG region :thinking: