I'm using Twilio conversations, First participant and second participant are OK
channelName is OK
Token is OK
The conversation of the user is shown on (the app with no problem) but on web I'm getting error below
Code >
const onConversationJoined = (conversation) => {
conversation.add(secondPerson.id).then(() => setConversation(conversation));
};
const onConversationFound = (conversation) => {
if (conversation.status !== "joined") {
conversation.join().then(onConversationJoined);
} else {
setConversation(conversation);
}
conversation.on("messageAdded", handleNewMessage);
onConnected();
};
const onConversationNotFound = (client) => {
client
.createConversation({
uniqueName: channelName,
})
.then(onConversationFound)
.catch((e) => console.log(e, "error")); << ERROR APPEAR HERE
};
if (token) {
const client = new Client(token);
client.on("stateChanged", (state) => {
if (state === "initialized") {
client
.getConversationByUniqueName(channelName)
// following line dont run..
.then(onConversationFound)
.catch(() => onConversationNotFound(client));
}
});
}
Error > with code https://www.twilio.com/docs/api/errors/50353
The error shown on console.log
Error: Conflict
at Upstream._callee$ (upstream.ts:179:1)
at tryCatch (regeneratorRuntime.js:86:1)
at Generator._invoke (regeneratorRuntime.js:66:1)
at Generator.next (regeneratorRuntime.js:117:1)
at asyncGeneratorStep (asyncToGenerator.js:3:1)
at _next (asyncToGenerator.js:25:1) 'error'
Thanks!
Twilio developer evangelist here.
It looks like you may have any Programmable Chat channels with the same name. When multiple participants are involved at roughly the same time, one may be creating the conversation and the other attempting to create it at the same time.