# Websocket connection failed

**URL:** <https://community.sendbird.com/t/websocket-connection-failed/5298>\
**Category:** Miscellaneous\
**Created:** [August 10, 2022, 11:14am UTC](https://community.sendbird.com/t/websocket-connection-failed/5298 "2022-08-10T11:14:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dip\_Pathak](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/dip_pathak/32/2870_2.png) [@Dip\_Pathak](https://community.sendbird.com/u/Dip_Pathak)\
**Post date:** [August 10, 2022, 11:14am UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/1 "2022-08-10T11:14:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![taha.saghir](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/taha.saghir/32/2094_2.png) [@taha.saghir](https://community.sendbird.com/u/taha.saghir)\
**Post date:** [August 15, 2022, 8:24pm UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/3 "2022-08-15T20:24:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Dip\_Pathak](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/dip_pathak/32/2870_2.png) [@Dip\_Pathak](https://community.sendbird.com/u/Dip_Pathak)\
**Post date:** [August 25, 2022, 4:06am UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/4 "2022-08-25T04:06:55Z")

</div>

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!

 ![image](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/d/d034db6a238eba3f4ef20557591799ce567ed884.png)

---

<div class="post-metadata">

**Author:** ![taha.saghir](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/taha.saghir/32/2094_2.png) [@taha.saghir](https://community.sendbird.com/u/taha.saghir)\
**Post date:** [August 26, 2022, 5:27pm UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/5 "2022-08-26T17:27:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dip\_Pathak](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/dip_pathak/32/2870_2.png) [@Dip\_Pathak](https://community.sendbird.com/u/Dip_Pathak)\
**Post date:** [August 29, 2022, 11:31am UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/6 "2022-08-29T11:31:46Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![taha.saghir](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/taha.saghir/32/2094_2.png) [@taha.saghir](https://community.sendbird.com/u/taha.saghir)\
**Post date:** [August 29, 2022, 3:40pm UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/7 "2022-08-29T15:40:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dip\_Pathak](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/dip_pathak/32/2870_2.png) [@Dip\_Pathak](https://community.sendbird.com/u/Dip_Pathak)\
**Post date:** [August 30, 2022, 3:22am UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/8 "2022-08-30T03:22:08Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Pallavi\_Aggarwal](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/pallavi_aggarwal/32/3106_2.png) [@Pallavi\_Aggarwal](https://community.sendbird.com/u/Pallavi_Aggarwal)\
**Post date:** [October 15, 2024, 9:06am UTC](https://community.sendbird.com/t/websocket-connection-failed/5298/9 "2024-10-15T09:06:03Z")

</div>

I am getting same error in swift send bird sdk 4.6
