Stack Overflow Asked by That1Guy on January 16, 2021
I created a chat client using Twilio, using their JavaScript client on the front end. I’m making the following call to get a channel by SID
let channel_promise = client.getChannelBySid(sid);
This worked fine for months, but now out of the blue I’m getting the following error:
twilio-chat.js:28610 Uncaught (in promise) Error: Not Found
at TwilsockUpstreamError.ExtendableBuiltin (twilio-chat.js:28610)
at TwilsockUpstreamError.TwilsockError (twilio-chat.js:28640)
at new TwilsockUpstreamError (twilio-chat.js:28719)
at Upstream._callee$ (twilio-chat.js:30068)
at tryCatch (twilio-chat.js:14232)
at Generator.invoke [as _invoke] (twilio-chat.js:14466)
at Generator.prototype.<computed> [as next] (twilio-chat.js:14284)
at step (twilio-chat.js:8227)
at twilio-chat.js:8238
ExtendableBuiltin @ twilio-chat.js:28610
TwilsockError @ twilio-chat.js:28640
TwilsockUpstreamError @ twilio-chat.js:28719
_callee$ @ twilio-chat.js:30068
tryCatch @ twilio-chat.js:14232
invoke @ twilio-chat.js:14466
prototype.<computed> @ twilio-chat.js:14284
step @ twilio-chat.js:8227
(anonymous) @ twilio-chat.js:8238
Promise.then (async)
success @ conversations.js:653
j @ jquery-1.11.0.min.js:2
fireWith @ jquery-1.11.0.min.js:2
x @ jquery-1.11.0.min.js:4
b @ jquery-1.11.0.min.js:4
XMLHttpRequest.send (async)
(anonymous) @ VM11:1
send @ jquery-1.11.0.min.js:4
ajax @ jquery-1.11.0.min.js:4
join_conversation @ conversations.js:617
dispatch @ jquery-1.11.0.min.js:3
r.handle @ jquery-1.11.0.min.js:3
I’m fetching the client library from their CDN and specifying the version, so I’m fairly confident this isn’t breaking due to a change in the client code.
<script src="https://media.twiliocdn.com/sdk/js/chat/v3.3/twilio-chat.js"></script>
I confirmed the channel SID I’m using is correct by logging it to console, and then using the twilio-cli to look up existing channels. The output from the cli matches the console output, so I know that I’m using the correct SID.
Does anyone have any idea why this call is failing? How can I get the channel without an error?
The code around the getChannelBySid
call is:
function join_conversation(){
// Get the SID
const sid = $(this).attr('data-sid');
// Log the SID for debugging purposes.
console.log(sid);
// Get the channel.
let channel_promise = client.getChannelBySid(sid);
channel_promise.then(async function(channel){
...
})
}
The SID is coming from the backend which uses the following code to fetch conversations:
from twilio.rest import Client
...
self.client = Client(self.account_sid, self.auth_token)
...
def get_conversations(self):
return self.client.conversations.conversations.list()
The Chat token is generated with the following code:
from twilio.jwt.access_token import AccessToken
from twilio.jwt.access_token.grants import ChatGrant
...
def generate_chat_token(self, identity, service_sid):
# Get a token.
token = AccessToken(self.account_sid, self.api_key, self.api_secret, identity=identity)
# Add a chat grant to the token.
grant = ChatGrant(service_sid=service_sid)
token.add_grant(grant)
return token.to_jwt()
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP