Weird history fetching behavior with chat on connect.

Hello,

We have an extremely simple chat setup in our game. Only one Global/public chat. The app is made in unity. The expected behavior is that when a user connect, it fetches the 100 last message (using the -1) param.

The issue is that it downloads a different "sets" of message when running the same code a few times in a row.
Example:

Sequence 1
*User Connect*
Fetches message A,B,C,D,E,F.
*Hard close app, disconnect from chat.*

Sequence 2 (Seems good)
*User Connect*
Fetches message A,B,C,D,E,F.
*Hard close app, disconnect from chat.*

Sequence 3
*User Connect*
Fetches message U,V,W,X,Y,Z (Usually older messages from earlier in the day)
*Hard close app, disconnect from chat.*

Sequence 4
*User Connect*
Fetches message U,V,W,X,Y,Z (Usually older messages from earlier in the day)
*Hard close app, disconnect from chat.*

Sequence 5 (Back to normal)
*User Connect*
Fetches message A,B,C,D,E,F.
*Hard close app, disconnect from chat.*

All of it in a 5 min session running the same code, with the same client. iOS/Android/PC, same behavior.

If feels as like there is "multiverse" channels but we always provide the same channel id; this is the code we use:

public void SetupChat(string userId)
{
this.UserId = userId;
ChatClient = new ChatClient(this);
ChatClient.ChatRegion = "EU";
ChatClient.Connect(MetaStateSettings.PhotonChatId, "1.00", new AuthenticationValues(userId));
}

public void OnConnected()
{
if (OnChatReconnected != null) OnChatReconnected.Invoke();
ChatClient.Subscribe(new string[] { "WorldChat" }, -1);
ChatClient.SetOnlineStatus(ChatUserStatus.Online);
}

//this is where object[] messages won't return the same result upon multiple connect (open/close app)
public void OnGetMessages(string channelName, string[] senders, object[] messages)
{
for (int i = 0; i < senders.Length; i++)
{
ChatMessageEntry chatMessageEntry = new ChatMessageEntry();
chatMessageEntry.UserID = senders;
chatMessageEntry.Message = messages.ToString();
chatMessageEntry.Channel = channelName;
AddMessage(chatMessageEntry);
}
}


Our chat usually have around 300-400 CCU all the time so it's not being "closed" from time to time.

Thanks!

Comments

  • Hi @DryGinStudios,

    Thank you for choosing Photon and for your report!

    Could you make sure clients end up on the same servers (chatClient.chatPeer.ServerIpAddress)?
    You connection snippet looks like clients should be on the same region, virtual application (AppId, AppVersion)...so maybe client end up on different servers OR on different channels (even if the same is unique)...the only way to find out is if two clients that subscribe to the same channel and get different history cannot exchange messages.

    I prefer that you send an email to [email protected] with your AppId and link to this forum discussion and any other details you might find intersting...like minimal 100% exact repro steps OR server addresses when chat history is different...
  • Okay cool, I replied via email with more details and screenshots.
Sign In or Register to comment.