WS connection going in the loop

Hello!
I have a problem with CometChat. At the moment none of our users can use CometChat. The main problem is that the WS connection going in the loop. It happens after calling the method await CometChat.init(appId, appSetting); and then the method await CometChat.login(this.chatInfo.user.authToken);. Moreover, the initialization process is successful, and an error occurs at the login function. Also in the network, I can see the call of two other methods: me and settings. “Me“ method processed successfully and returns 200 status code. While “settings” method returns error: code: "AUTH_ERR_INVALID_APPID"devMessage: "The appId undefined does not exists in us region."message: “The appId undefined does not exists in us region.”.
Also, I would like to provide you with some additional information about how we use the CometChat. We’re using CometchatAngularUiKitModule “@cometchat-pro/chat”: “^2.1.0” from the UI side and CometChat REST API from the backend side. We have 11 extensions enabled though use only 5 of them: Data Masking, Emojis, Profanity Filter, Reactions, XSS Filter. According to the CometChat statistics, at this moment we have 525 Monthly active users, 2772 Messages, and 706 Total Users.
In the end, I want to add that we send a request to cometChat every 5 seconds for each user to update the message counter on the toolbar. That’s why I suspect that the problem was caused by the number of users and the requests we send.
What course the problem and how we can fix it?

Hello @Natalia ,

Can you please update to js SDK v2.1.7. Also, can you please let us know if you are clearing local storage by any chance? And please make sure you are calling CometChat.init() on reload of the page. Can you please let us know which API call are you making in every 5 seconds?

Warm Regards,

CometChat Pro
Mayur Bhandari

No, I do not clear local storage.
Yes, I call CometChat.init() after reload and get the same error. Here is the code fragment of the chat initialization:
if (!CometChat.isInitialized()) {
await CometChat.init(appId, appSetting);
}
this.loggedInUser = await CometChat.getLoggedinUser();
if (!this.loggedInUser) {
await CometChat.login(this.chatInfo.user.authToken);
}
I call the getUnreadMessageCountForAllGroups function every 5 seconds in order to fetch the unread message counts.
I will try to update js SDK v2.1.7 and info you if it helps.

The interesting fact is that when I switched to another CometChat application with the trial version the error vanished. Could this problem be CometChat application-specific?

Unfortunately, the js SDK v2.1.7 update did work for me.

Hello @Natalia ,

Did updating the SDK version work for you or are you still facing the issue.

Warm Regards,

CometChat Pro
Mayur Bhandari

Unfortunately, we still facing this issue.
We suspect that we have exceeded the limit of the number of users. According to the CometChat statistics, at this moment we have 525 Monthly active users, 2772 Messages, and 706 Total Users.
For about a day, the number of active users is 300. Our plan is MOON 10K.
Do you think this could be the problem?

Hello @Natalia ,

That cannot be the issue. However, after running a few tests on our end using the appID which was shared by one of your colleagues with us over email we were able to reproduce the issue and made some changes at our end. Can you please check if it is working fine on your end?

Warm Regards,

CometChat Pro
Mayur Bhandari

Hello!
The issue with loop ws is fixed and our users can finally get access to the chat. But we faced a new error. Earlier “ws” requests used to fail to connect due to timeout, now we are observind a “wss://2225328899422b3.ws-us.cometchat.io/ws/” request that is staying in a pending state for almost 8 minutes. Due to this, our users can receive new messages only after refreshing the page.
Could you please check this issue on your side?

Hello @Natalia ,

When the WS connects it will remain in pending state. So that is not an issue. What happens after you refresh the page? Do the users have to refresh the page from time to time to get real time messages?

Warm Regards,

CometChat Pro
Mayur Bhandari

Hello @mayur.bhandari

I’m working with Natalia on the issue and can describe the current behavior.

Right, now we use the application 2225328899422b3 on prod env and notice the following issues:

  • Chat groups are loaded but we need to refresh the page to make new messages appear.
  • When we get new messages, the unread message counter increases, but when we read them - it is not reset to 0.

We have the same version of our code on stage env but with another comet chat application (2882378113d5280) - and it works fine.

Also, I tested some scenarios locally:

  • with sdk 2.1.7 and application 2225328899422b3 - chat messages were loaded in chrome but not in firefox; when I sent a message - I received it multiple times (duplicates); chat worked too slowly
  • with sdk 2.1.7 BUT with another application (2882378113d5280) and with the same code - chat worked fine, fast, without bugs, on chrome and firefox.

So at the moment it looks like something is wrong with application, not with our code or sdk.

Thanks,
Kate

Hello @kate,

We are actively looking into this. As per our communication via email, we will be getting on a call in a couple of hours of time so that we can debug this and get to the root of the issue.

Warm Regards,

CometChat Pro
Mayur Bhandari