You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Communication Services群组通话踢人及同步异常技术咨询

关于Azure Communication Services(ACS)视频会议的核心问题

背景

我基于ACS搭建视频会议系统,由于Call Automation不支持Room Call,采用groupCall实现。目前客户端已完成加入通话、显示成员、静音等基础功能。

房主离开后无法全员踢出的问题

已配置Webhook并能捕获Microsoft.Communication.CallParticipantRemoved事件,可正确识别房主离开,但执行全员挂断操作时出现异常:

  • 调用await callConnection.hangUp(true):函数无报错,后续无法获取通话属性(提示通话已不存在),但客户端用户仍处于通话状态,未被踢出。
  • 调用await callConnection.removeParticipant(participant.identifier):返回错误{"code":"8501","details":{"error":{"code":"8501","message":"Action is invalid when call is not in Established state"}}},但实际通话仍在正常运行。

安全隐患:客户端可随意加入任意群组

客户端使用服务器生成的token,能够加入任意有效GUID的groupId;即使服务器执行挂断操作后,用户仍可通过同一groupId重新加入,甚至直接使用任意有效GUID创建并加入群组,怀疑客户端与服务器的Call实例存在不同步问题。


生成token代码

const generateToken = async (communicationUserId?: string) => {
    let CommunicationUserIdentifier

    const identityClient = new CommunicationIdentityClient(
        envConfig.AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING
    )

    if (!communicationUserId) {
        CommunicationUserIdentifier = await identityClient.createUser()
        console.log(`\nCreated an identity with ID: ${CommunicationUserIdentifier.communicationUserId}`)
    } else {
        CommunicationUserIdentifier = {
            communicationUserId: communicationUserId
        }
        console.log(`\nIdentity used is ID: ${CommunicationUserIdentifier.communicationUserId}`)
    }

    // Issue an access token with a validity of 24 hours and the "voip" scope for an identity
    let tokenResponse = await identityClient.getToken(CommunicationUserIdentifier, ['voip'])

    // Get the token and its expiration date from the response
    const { token, expiresOn } = tokenResponse
    console.log(`\nIssued an access token with 'voip' scope that expires at ${expiresOn}:`)

    return token
}

创建groupCall代码

const groupCall = await callAutomationClient.createGroupCall(
            [
                {
                    communicationUserId: acsUserId
                }
            ],
            `${envConfig.SERVER_URL}/callback`
        )
        const acsCallId = (await groupCall.callConnection.getCallConnectionProperties()).callConnectionId!

客户端加入通话代码

const credential = new AzureCommunicationTokenCredential(generatedToken);
const callClient = new CallClient();
callAgent = await callClient.createCallAgent(credential);
call = callAgent.join({ groupId: acsCallId }, callOptions);

服务器踢人尝试代码

const callConnection = callAutomationClient.getCallConnection(callId)
await callConnection.hangUp(true)

内容的提问来源于stack exchange,提问作者MEXII

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 18:22:40