我正在使用Twilio Client SDK和Salesforce从浏览器进行呼叫,这给了我奇怪的行为,有时它成功地建立了连接并能够进行呼叫,有时给了我错误,Toke不允许传出电话。这是dbug:
VM3217 twilio.min.js:55 Setting up VSP
VM3217 twilio.min.js:55 WSTransport.open() called...
VM3217 twilio.min.js:55 Attempting to connect...
VM3217 twilio.min.js:55 Closing and cleaning up WebSocket...
VM3217 twilio.min.js:55 No WebSocket to clean up.
VM3217 twilio.min.js:55 Device callback handlers (connect, error, offline,
incoming, cancel, ready, disconnect) have been deprecated and will
be removed in the next breaking release. Instead, the EventEmitter
interface can be used to set event listeners. Example: device.on('incoming', handler)
Log.log @ VM3217 twilio.min.js:55
Log.warn @ VM3217 twilio.min.js:55
Device._addHandler @ VM3217 twilio.min.js:55
Device.incoming @ VM3217 twilio.min.js:55
(anonymous) @ TwilioClick2Dial?ph=923334178796&time=1:41
TwilioClick2Dial?ph=923334178796&time=1:61 before!!!
VM3217 twilio.min.js:55 WebSocket opened successfully.
VM3217 twilio.min.js:55 [PStream] Setting token and publishing listen
VM3217 twilio.min.js:55 [Twilio.PeerConnection] signalingState is "have-
local-offer"
VM3217 twilio.min.js:55 Received HANGUP from gateway
VM3217 twilio.min.js:55 Received an error from the gateway: {code: 31002,
connection: Connection, message: "Token does not allow outgoing calls."}
Log.log @ VM3217 twilio.min.js:55
Log.error @ VM3217 twilio.min.js:55
Connection._this._onHangup @ VM3217 twilio.min.js:55
emitOne @ VM3217 twilio.min.js:55
emit @ VM3217 twilio.min.js:55
PStream._handleTransportMessage @ VM3217 twilio.min.js:55
emitOne @ VM3217 twilio.min.js:55
emit @ VM3217 twilio.min.js:55
WSTransport._this._onSocketMessage @ VM3217 twilio.min.js:55
VM3217 twilio.min.js:55 Uncaught error event suppressed.
VM3217 twilio.min.js:55 Disconnecting...
VM3217 twilio.min.js:55 [Twilio.PeerConnection] iceConnectionState is
"closed"
VM3217 twilio.min.js:55 [Twilio.PeerConnection] signalingState is "closed"
答案 0 :(得分:0)
您可能使用的令牌没有“允许传出连接”功能令牌。
要使用twilio客户端,您需要一个令牌,该令牌由您的帐户SID,您的auth令牌以及您希望允许令牌用户使用的功能列表创建。
例如,要生成具有拨出电话功能的令牌,将是这样的:
account_sid = 'ACXXXXXXXXXXXXXXX'
auth_token = 'secret'
application_sid = 'AP123123'
capability = ClientCapabilityToken(account_sid, auth_token)
capability.allow_client_outgoing(application_sid)
print(capability.to_jwt())
您可以参考following doc page来了解如何创建具有不同功能的令牌。