Twilio JS-Client.getChannelBySid引发错误:未找到

问题描述

我使用Twilio前端的JavaScript client创建了一个聊天客户端。我正在拨打以下电话以获得频道by SID

let channel_promise = client.getChannelBySid(sid);

这可以正常工作几个月,但是现在突然出现以下错误

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

我正在从其CDN中获取客户端库并指定版本,因此我非常有信心这不会因为客户端代码的更改而中断。

<script src="https://media.twiliocdn.com/sdk/js/chat/v3.3/twilio-chat.js"></script>

通过将其登录到控制台,然后使用twilio-cli查找现有通道,我确认了所使用的通道SID是正确的。 cli的输出与控制台输出匹配,因此我知道我使用的是正确的SID。

有人知道为什么此呼叫失败吗?如何获得没有错误的频道?


getChannelBySid调用周围的代码是:

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){
        ...
    })

}

SID来自后端,该后端使用以下代码获取对话:

from twilio.rest import Client

...

self.client = Client(self.account_sid,self.auth_token)

...

def get_conversations(self):
    return self.client.conversations.conversations.list()

使用以下代码生成聊天令牌:

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()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...