使用SIP/{Number}@{Provider}格式呼叫时如何添加transport=udp参数
transport=udp in SIP INVITE URI for SIP/{Number}@{Provider} Dial Format Got it, let's tackle this issue where your SIP/{Number}@{Provider} dial format isn't including the transport=udp parameter in the SIP INVITE request URI, even though the SIP/{Provider} format works fine. Here are a few straightforward solutions depending on your PBX setup (I'll use Asterisk examples since it's the most common, but the logic applies to most systems):
Explicitly append the transport parameter in your dial plan
If you're using a dial plan rule that constructs the SIP URI directly, just add;transport=udpto the end of the target. For example, if your original rule looks like this:exten => _X.,1,Dial(SIP/${EXTEN}@{Provider})Update it to:
exten => _X.,1,Dial(SIP/${EXTEN}@{Provider};transport=udp)This forces the transport parameter to be included every time this dial pattern is used, no matter the format.
Set a default transport for your SIP provider
Head into your SIP configuration file (likesip.conffor Asterisk) and add thetransport=udpparameter to your provider's peer definition. This makes UDP the default transport for all calls to that provider, so the parameter will automatically be added to the INVITE URI regardless of the dial format you use. Example:[Provider] type=peer host=your-provider-domain.com transport=udp ; Keep your existing config parameters hereUse dial plan functions for dynamic parameter addition (for advanced cases)
If you need more flexibility (like switching transport protocols based on conditions), you can build the URI dynamically. In Asterisk, this would look like:exten => _X.,1,Set(TARGET=SIP/${EXTEN}@{Provider}) exten => _X.,n,Set(TARGET=${TARGET};transport=udp) exten => _X.,n,Dial(${TARGET})This lets you add extra logic before dialing if needed.
The core idea here is ensuring the transport=udp parameter is either hardcoded into your dial string or set as a default for the provider. Most SIP systems won't automatically add this parameter when you include a number in the URI, so explicit configuration is the way to go.
内容的提问来源于stack exchange,提问作者Abhinav Nimesh

