PhotonChat JavaScript SDK doesn't load messages history

Hello. As I know, channel history is being stored in PhotonChat memory until this channel gets destroyed. And it's true - PhotonChat calls the ChannelDestroy webhook of my backend with valid channel state. But the problem is that JavaScript SDK doesn't load this messages even if some clients are connected to a channel. It only loads history if I have 2 tabs opened in my browser with the same session (e.g. when 2 clients are connected to PhotonChat with same user ID). But if there's another user which is connected to specific channel, I don't get this messages back when I connect with another account. Is it a bug on my side or is it an issue of JavaScript SDK? Thank you.

Comments

  • Hi @rjkz808,

    What "subscribe options" param/arg do you use in the "chatClient.subscribe" function call?
    You need to at least set "options.historyLength = -1".
  • JohnTube wrote: »
    Hi @rjkz808,

    What "subscribe options" param/arg do you use in the "chatClient.subscribe" function call?
    You need to at least set "options.historyLength = -1".

    I set its value to 10 at the moment
  • JohnTubeJohnTube mod
    edited January 16
    Hi @rjkz808,

    And with 10 you get messages or not?
    Are you sure clients are on the same region and use the same AppId/AppVersion?
    Do you use webhooks and load channel state or not?
  • @JohnTube

    1. I don't get any messages that have been sent.
    2. Yes, two clients use the same configuration
    3. What do you mean by loading channel state? I use ChannelCreate and ChannelSubscribe webhooks to validate users connection to specific channel.
  • Hi @JohnTube, do I need to provide more info on this issue?
  • Hi @rjkz808,

    I think I understand the problem: subscribing to a channel does not get its history in JavaScript SDK even if the channel still exists (another user is subscribed to it).

    @vadim could you look into this?
  • vadimvadim ✭✭✭
    Hi,

    I tested message history with demo-chat-api application from js sdk package. Message history works for me if historyLength set to 10 or -1 or omitted in chatClient.subscribe() call. Removing 'lastIds' parameter from the call does not change the behavior.
    I opened 1 app instance, connected, subscribed to 3 channels and sent some to messages to each. Then in other browser window, I connected and subscribed with other user id and received all the history.
    Please let me know if my test does not cover your case.
  • Hi @vadim and @JohnTube, I think I have an idea on this one. I found out that if I disable custom authentication (removing line with setCustomAuthentication call) it starts to work. So, in my opinion it won't work only if you enable custom authentication provider in PhotonChat SDK.
  • And I also think that it's a bug on PhotonChat JS SDK side
Sign In or Register to comment.