我使用 zoom 的 API、jwt 和 websdk 在按钮单击时创建会议,然后作为主持人加入并同时开始会议,使其他人能够加入。这在本地工作正常,但不知何故,当部署到 cloudflare 时,我收到以下错误:
您的连接已超时,您无法加入会议。验证您的网络连接并重试。
错误对象:
errorCode: 3706
errorMessage: undefined
method: "join"
result: "The meeting number is wrong."
status: false
“会议号码错了。” 这里显然是错误的信息,因为提供的会议号直接来自 zoom 的 API,并且在本地工作。
const joinMeeting = async (meetConfig: MeetConfigData) => {
const ZoomMtg = require("@zoomus/websdk").ZoomMtg;
ZoomMtg.setZoomJSLib("https://source.zoom.us/1.9.0/lib", "/av");
ZoomMtg.preLoadWasm();
ZoomMtg.prepareJssdk();
const signature = await generateSignature(meetConfig.role, meetConfig.meetingNumber);
ZoomMtg.init({
leaveUrl: meetConfig.leaveUrl,
isSupportAV: true,
success: () => {
ZoomMtg.join({
signature,
apiKey: "API_KEY",
meetingNumber: meetConfig.meetingNumber,
userName: meetConfig.userName,
passWord: meetConfig.password,
success: () => {
console.log("Successfully hosted or joined meeting.");
},
error: (err: Error) => {
console.log("Error: ", err);
},
});
},
error: (err: Error) => {
console.log("Error: ", err);
},
});
};
服务器端签名方法返回正确的签名,因为它再次在本地工作:
export const createSignature = ({ role, meetingNumber }) => {
const timestamp = new Date().getTime() - 30000;
const msg = Buffer.from(
process.env.NEXT_PUBLIC_ZOOM_API_KEY + meetingNumber + timestamp + role
).toString("base64");
const hash = crypto
.createHmac("sha256", process.env.NEXT_PUBLIC_ZOOM_API_SECRET)
.update(msg)
.digest("base64");
return Buffer.from(
`${process.env.NEXT_PUBLIC_ZOOM_API_KEY}.${meetingNumber}.${timestamp}.${role}.${hash}`
).toString("base64");
};
有没有人经历过这个?