{"record":{"id":"c15a1e5bdfdb1e3e","repo":"RocketChat/Rocket.Chat","slug":"error-max-number-simultaneous-chats-reached","errorCode":"error-max-number-simultaneous-chats-reached","errorMessage":"error-max-number-simultaneous-chats-reached","messagePattern":"error-max-number-simultaneous-chats-reached","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/meteor/ee/server/hooks/omnichannel/beforeJoinRoom.ts","lineNumber":30,"sourceCode":"\t\tif (!settings.get('Livechat_waiting_queue')) {\n\t\t\treturn user;\n\t\t}\n\n\t\tif (!room || !isOmnichannelRoom(room)) {\n\t\t\treturn user;\n\t\t}\n\t\tconst { departmentId } = room;\n\t\tconst userSubs = await Users.getAgentAndAmountOngoingChats(user._id, departmentId);\n\t\tif (!userSubs) {\n\t\t\treturn user;\n\t\t}\n\t\tconst { queueInfo: { chats = 0, chatsForDepartment = 0 } = {} } = userSubs;\n\n\t\tif (await isAgentWithinChatLimits({ agentId: user._id, departmentId, totalChats: chats, departmentChats: chatsForDepartment })) {\n\t\t\treturn user;\n\t\t}\n\n\t\tthrow new Error('error-max-number-simultaneous-chats-reached');\n\t},\n\tcallbacks.priority.MEDIUM,\n\t'livechat-before-join-room',\n);\n","sourceCodeStart":12,"sourceCodeEnd":35,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/hooks/omnichannel/beforeJoinRoom.ts#L12-L35","documentation":"Thrown by the `beforeJoinRoom` omnichannel hook (MEDIUM priority, `livechat-before-join-room`) when an agent joining a livechat room would exceed configured chat limits. It is a plain `Error` with code-like message `error-max-number-simultaneous-chats-reached`. Limits come from the agent's per-agent cap, the global `Livechat_maximum_chats_per_agent` setting, and/or the department's `maxNumberSimultaneousChat`.","triggerScenarios":"An agent (livechat-managed user) joins a livechat room; `getAgentAndAmountOngoingChats` returns their current counts; `isAgentWithinChatLimits` returns false because total chats and/or department chats exceed the effective limit.","commonSituations":"Agent at their concurrent chat cap tries to take another conversation; department concurrency limit reached; global `Livechat_maximum_chats_per_agent` set low and agent is saturated.","solutions":["Finish/close one of the agent's ongoing chats before joining another.","Raise the per-agent `maxNumberSimultaneousChat`, the global setting, or the department's `maxNumberSimultaneousChat`.","Route the conversation to another available agent via the queue."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { isAgentWithinChatLimits } from '../../lib/omnichannel/Helper';\n\nasync function agentCanJoin(user: { _id: string }, departmentId: string): Promise<boolean> {\n\tconst userSubs = await Users.getAgentAndAmountOngoingChats(user._id, departmentId);\n\tif (!userSubs) return true;\n\tconst { queueInfo: { chats = 0, chatsForDepartment = 0 } = {} } = userSubs;\n\treturn isAgentWithinChatLimits({ agentId: user._id, departmentId, totalChats: chats, departmentChats: chatsForDepartment });\n}","typeGuard":"function isMaxSimultaneousChatsError(e: unknown): boolean {\n\treturn e instanceof Error && e.message === 'error-max-number-simultaneous-chats-reached';\n}","tryCatchPattern":"try {\n\tawait callbacks.run('beforeJoinRoom', user, room);\n} catch (e) {\n\tif (e instanceof Error && e.message === 'error-max-number-simultaneous-chats-reached') {\n\t\t// route to another agent or raise the limit\n\t}\n\tthrow e;\n}","preventionTips":["Pre-check `isAgentWithinChatLimits` before joining a room.","Tune per-agent, global, and department chat limits to realistic values.","Use the waiting queue to distribute load instead of manual joins."],"tags":["omnichannel","livechat","rate-limit","agents","ee"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}