0
votes

I'm trying to implement this project: https://github.com/twilio/twilio-video-app-react

I got error "There was a problem getting the Conversation associated with this room." when the ChatProvider did mount. Seem like chatClient can't find the conversation with room.sid but I can't figure out how to create conversation when it doesn't exist and add participants when conversation existed. Does anyone know this issue? Thanks!

Update: the server code: https://gist.github.com/qngnud/c9910afada625a9a4eceb3ad3a67d3b7

2
Have you set the TWILIO_CONVERSATIONS_SERVICE_SID in the env file? Are there errors on the server side that you can share?philnash
@philnash Hi, sorry about reply lately, I write all my id, token directly into my code and my server doesn't show any error, this is my server code: gist.github.com/qngnud/c9910afada625a9a4eceb3ad3a67d3b7dungreact

2 Answers

1
votes

Twilio developer evangelist here.

It appears that you are using similar code to the original app in your server, however you have missed a crucial keyword.

The part of the code where you try to fetch a conversation by the room.sid is surrounded by a try/catch, however it is called in promise form, so any failures will be picked up by a chained .catch() function.

In the original code, the calls are made using the await keyword which turns promises into code that appears synchronous and, most importantly, in which errors can be caught by a try/catch block.

So, you should either move your catch blocks to .catch() promise chains, or declare the whole function async and use await before the asynchronous function calls.

0
votes

I fixed this issue by adding member in the channel before joining the twilio room.

To add member in the channel, I used the api provided by twilio => Click here.

After adding the member in the channel, ChatClient will find the conversation with roomSid.

And I used chatClient.getConversationBySid('CHXXXXXXXXXXXXXXXXXXXXXX') instead chatClient.getConversationByUniqueName(room.sid).

Happy Coding!