当我在使用 twilio 时尝试从一个 iOS 客户端向另一个 iOS 客户端拨打电话时,收到此错误“无法连接到房间,并出现错误:SIP 错误 403”视频SDK为了迅速。
当我使用手动生成的 twilio 访问令牌(从 Twilio 控制台获取)并将其插入客户端应用程序时,我可以拨打电话(Xcode 到移动设备和移动设备到移动设备)。但是,当我尝试使用 Twilio 提供的以下服务器代码通过 NodeJS 服务器以编程方式从 Twilio 获取令牌时,出现上述错误。即使使用安全连接 (HTTPS) 从 Twilio 获取令牌,该错误仍然存在。
下面是 Xcode 的日志,
2017-01-13 07:30:47.625 VideoCall[39299:25726155] Attempting to connect to room Optional("testRoom")
2017-01-13 07:30:47.625 VideoCall[39299:25726155] provider:didActivateAudioSession:
2017-01-13 07:30:51.255 VideoCall[39299:25726155] Failed to connect to room with error: SIP error 403
2017-01-13 07:30:51.272 VideoCall[39299:25726155] provider:didDeactivateAudioSession:
2017-01-13 07:32:52.168 VideoCall[39299:25729470] ERROR:TwilioVideo:[Signaling]:RESIP::TRANSPORT: Got TLS read ret=0 error=6 error:00000006:invalid library (0):OPENSSL_internal:public key routines
NodeJS 服务器代码(由 Twilio 提供)
var express = require('express');
var router = express.Router();
var AccessToken = require('twilio').AccessToken;
// Substitute your Twilio AccountSid and ApiKey details
var ACCOUNT_SID = 'accountSid';
var API_KEY_SID = 'apiKeySid';
var API_KEY_SECRET = 'apiKeySecret';
var TWILIO_CONFIGURATION_SID = 'twilioConfigurationSid';
router.get('/getTwilioVideoAccessToken', function(req, res, next) {
// Create an Access Token
var accessToken = new AccessToken(
ACCOUNT_SID,
API_KEY_SID,
API_KEY_SECRET
);
var identity = 'example-user';
// Set the Identity of this token
accessToken.identity = identity;
// Grant access to Conversations
var grant = new AccessToken.ConversationGrant();
grant.configurationProfileSid = TWILIO_CONFIGURATION_SID;
accessToken.addGrant(grant);
// Serialize the token as a JWT
var jwt = accessToken.toJwt();
console.log(jwt);
res.json({"token": jwt, "statusCode" : 200, "identity":identity})
});
解决方案:
Twilio 客户支持建议我使用了不正确的 API_KEY_SECRET,这导致了错误,@Aubtin Samai 也指出了这一点。
可以按照提供的说明生成 API_KEY_SECREThere.