Getting old messages after reconnect a room

Options
HisAirness
edited August 2019 in Photon Chat
Hi guys,

I created two separate rooms and sent a private message from "player1" who is in "room1" to "player2" who is in "room2". Player2 received the private message successfully. After that, Player2 leave "room2" and joined "room1". After joining, Player2 received the old message from Player1 again (Player1 didn't send it again). How can I prevent this?

Thanks.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @HisAirness,

    Thank you for choosing Photon!

    What client SDK are you using?
    What version?

    In Photon Chat, there are channels and not rooms.
    You are maybe referring to rooms from Photon Realtime or PUN as you are probably combining both products.

    Anyways, it looks like you are subscribing to the same channel and requesting history.
    A channel can have up to 100 messages in history.
    Empty channels where no one is still subscribed will be destroyed on Photon servers after a timeout.
    So either subscribe to a new channel (new name) or do not request channel history messages from the server when subscribing.
  • LoTher05
    Options
    Hello @JohnTube ,
    The same problem also happened to us. Old messages was being received upon connection to PhotonChat is established. Player didn't subscribe to the channel yet but the message received was considered as new but it was already received by the Player. It happens randomly tho.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2020
    Options
    Hi @LoTher05,

    Thank you for choosing Photon!

    What client SDK do you use? which version?
    Did this happen with different Photon Chat AppIDs?
    Did this happen with different Photon Chat AppVersion?
    Did this happen on multiple Photon Cloud regions?
    Do you have more details about how to repro this?
    Does this happen when the client reconnects after unexpected disconnection or in an initial connection?
  • LoTher05
    Options
    Hello @JohnTube ,

    What client SDK do you use? which version? - We're using the PhotonChatApi in PUN v1.102
    Did this happen with different Photon Chat AppIDs? - we only use 1 Photon Chat AppIDs
    Did this happen with different Photon Chat AppVersion? - it happened before but not every time, it happens occasionally and we don't know yet the reason why.
    Did this happen on multiple Photon Cloud regions? - We only use 1 region which is EU
    Do you have more details about how to repro this? - I can't say any specific but it happens to account that is always connected or online for long hours.
    Does this happen when the client reconnects after unexpected disconnection or in an initial connection? - it happens during initial connection. Tried to open the message channel with the new message > Disconnect > then the message keep arriving.

    After sometime, it will not happen and we still don't know why.
  • Afterlife1707
    Options
    Was there any fix found on this? I'm also having the same issue
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Afterlife1707,

    Thank you for choosing Photon!

    Continuing here after starting discussion on discord.
    Do you disconnect and reconnect Photon Chat client in between or simply subscribe and unsubscribe? or pause (background) app and unpause (foreground)?
    If you disconnect and reconnect? Do you keep the same Photon Chat client UserId between sessions?

    I assume this is Photon Chat from PUN 2.31.
  • Afterlife1707
    Options
    Hi, I managed to fix the issue. I unsubscribed and disconnected the chat client in the photon disconnect function and now its fine. I guess it wasn't disconnecting earlier. This is the code I wrote:
    public override void OnDisconnected(Photon.Realtime.DisconnectCause cause)
    {
    chatClient.Unsubscribe(new string[] { chatRoomName });
    chatClient.Disconnect();
    }