Websocket connection failed

Hi,

I am using react native and trying to connect sendbird as follows:
const sendbird = new SendBird({ appId });
const connect = () => {
sendBird.connect(userID, tkn, (user, err) => {
if (!err) {
console.log("user =====>>> ", user);
// login api call
onLogin();
} else {
console.log("err ====>>> ", err);
Toast.show(err.message);
setState({ …state, loading: false });
}
});
}

But I am getting an error saying that SendBirdException: Websocket connection failed.
My react native and sendbird versions are 0.68.2 and 3.1.23 respectively.
Could you please help me out here?

Thanks

Hi @Dip_Pathak - welcome to the Sendbird community!

Apologies for the delayed response. Can you please post the network logs from your browser and DM me your App ID if you are still seeing the issue?

Hi @taha.saghir Thanks for welcoming me to the community.

Apologies for the delayed response. Currently, the same code is working fine without any issues. The issue that I had faced and mentioned above is gone. How? I have no idea about that, but it’s gone.

I have another query that I need to ask, I want to update messages array that I get from sendbird channel. I am fetching all messages using “channel.createPreviousMessageListQuery” and I am getting all the messages in an array. Now, I want to update the array by adding new message object in the very same array, but unfortunately, I am unable to do so.
As you can see in the first screenshot attached, I getting the “r” key before the object. In the second screenshot attached, you can see I have added a new meesage object but as I am not able to get the “r” key before the object, which is why I am not able to proceed futher.

Could you please help me out here?

Thanks!

Hi @Dip_Pathak - thanks for the update!

What is your use case for updating the array? Instead of mutating the original array, you can try creating a new array with a sequence of JSON.stringify and JSON.parse functions.

@taha.saghir Hi,
Thanks for the update, I actually want to group the messages by days. I will work on the solution you’ve provided and update you if it works out.

1 Like

Not sure which JS framework you are using but curious, can you group the messages when rendering the UI instead of manipulating the array?

Hi @taha.saghir ,
I am actualy working on Aurelia framework i.e., React Native and in order to render the UI I need to manipulate the array. So, If I have to display all the messages grouped by day.

Thanks!

1 Like