sip icon indicating copy to clipboard operation
sip copied to clipboard

Flood calls are creating new Room/Job when Dispatch is Any but TrunkID is empty

Open mercuryyy opened this issue 10 months ago • 4 comments

When using

│ SipDispatchRuleID │ Name │ SipTrunks │ Type                │ RoomName              │ Pin │ Attributes │ Agents    │
├───────────────────┼──────┼───────────┼─────────────────────┼───────────────────────┼─────┼────────────┼───────────┤
│ SDR_***  │      │ <any>     │ Individual (Caller) │ in-_<caller>_<random> │     │ map[]      │ *****-agent │

its causing requests like

{'event': 'participant_joined', 'room': {'sid': 'RM_DwDHCXtC8dun', 'name': 'in-_*_uD3hEq6noPra', 'emptyTimeout': 300, 'departureTimeout': 20, 'creationTime': '1743339898', 'creationTimeMs': '1743339898086', 'turnPassword': 'Axk62TYJp6fy35z6MJfO2At5Udb6WNL6zOtuhG7GT7b', 'enabledCodecs': [{'mime': 'audio/opus'}, {'mime': 'audio/red'}, {'mime': 'video/VP8'}, {'mime': 'video/H264'}, {'mime': 'video/VP9'}, {'mime': 'video/AV1'}, {'mime': 'video/rtx'}]}, 'participant': {'sid': 'PA_Ga72ZChbseAS', 'identity': 'sip_*', 'state': 'ACTIVE', 'joinedAt': '1743339898', 'joinedAtMs': '1743339898091', 'name': 'Phone *', 'version': 2, 'permission': {'canSubscribe': True, 'canPublish': True, 'canPublishData': True, 'canUpdateMetadata': True}, 'kind': 'SIP', 'attributes': {'sip.callID': 'SCL_kGJ9p5GgAnaa', 'sip.phoneNumber': '*', 'sip.ruleID': 'SDR_***', 'sip.trunkID': '', 'sip.trunkPhoneNumber': '11**15042301205'}}, 'id': 'EV_WFLZQd9TYfwS', 'createdAt': '1743339899'}

To Get pushed in and open a room

We added

async def entrypoint(ctx: JobContext):
....
            participant_attributes = participant.attributes
            trunkID = participant_attributes.get("sip.trunkID", "Unknown")
            if trunkID == 'Unknown':
                logger.info(f"Shutting down Agent this is SPAM")
                return

But shouldn't we want to have inbound requests with sip.trunkID not open a new livekt room and init a Job by default ?

mercuryyy avatar Mar 30 '25 13:03 mercuryyy

Are you self-hosting SIP? If so, just create a new Trunk and bind a dispatch rule to it instead.

dennwc avatar Mar 30 '25 13:03 dennwc

Yes Self hosting, we plan to have 100's/1000's of inbound trunks created that is why we reverted to try and use Dispatch any.

Blocking these requests at the SIP server or at the point where it decide if to open a Room/job would probably be the expected behavior when no trunkid i would assume

mercuryyy avatar Mar 30 '25 13:03 mercuryyy

There are a few options here. SIP now supports update APIs, so you could update old trunks instead of creating new ones.

But in other cases, this behaviour would need to be configured in the main LiveKit server. We could enforce the same policy as Cloud does, that is - reject calls that match no trunks. We cannot enable it by default, since some users already rely on this behaviour.

dennwc avatar Mar 31 '25 12:03 dennwc

Yeah we build our own logic to edit redis and we were updating the "Dispatch" trunk_ids dynamically but i figured having 1 dispatch with vs 1000's is more ideal

I would suggest maybe putting it on the roadmap? If trunkid is empty there is no logic in opening a new Room/Job its will probably improve/save on the main LiveKit Cloud servers :)

mercuryyy avatar Mar 31 '25 13:03 mercuryyy