PJSIP dial with host

I’m trying to update some server from chan_sip to pjsip, and I’m looking to replicate/replace some functionality in our dialplan. In the chan_sip dialplan, we would use Dial(SIP/1234@10.5.21.104) and that would dial outbound without a SIP Peer. Trying to do the same with pjsip, Dial(PJSIP/1234@10.5.21.104) give me the below logs and errors. From the pjsip troubleshooting wiki, it sound like I need to create an endpoint. Is there a way to dial without an endpoint or have a generic endpoint? Also would there be issue with an Asterisk server running chan_sip dialing an Asterisk server running pjsip?

Executing [100@testing:3] Dial(“PJSIP/6001-00000005”, “PJSIP/1234@10.5.21.104”) in new stack
[Oct 15 00:38:53] ERROR[33]: chan_pjsip.c:2645 request: Unable to create PJSIP channel - endpoint ‘10.5.21.104’ was not found
[Oct 15 00:38:53] WARNING[83][C-00000006]: app_dial.c:2578 dial_exec_full: Unable to create channel of type ‘PJSIP’ (cause 3 - No route to destination)
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [100@testing:4] Hangup(“PJSIP/6001-00000005”, “”) in new stack

Third example.

To further elaborate, there is always an endpoint as it defines the configuration to use for the session and there is nothing stopping you from making an endpoint specifically for dialing URIs.

Thanks David! I was able to get an outbound dial working with that example. Must’ve overlooked that wiki page when looking around.

making an endpoint specifically for dialing URIs

How would the pjsip.conf look for that? I’m still learning the pjsip config options, and I find that examples can be hard to come by for specific scenarios.

[outbound]
type=endpoint
disallow=all
allow=ulaw

That’s as slim as you can go. You’d just use:

PJSIP/outbound/sip:1000@voip.com

That works beautifully! Thanks! Do you have an example for unauthed inbound traffic? I have the below config so far, but it is still responding with a SIP 401 Unauthorized. I’ve tried playing around with the auth field on the endpoint, but haven’t had much luck.

[transport-udp]
type=transport
bind=0.0.0.0
local_net=10.0.0.0/8
[inbound]
type=endpoint
allow=ulaw
disallow=all
context=inbound
sdp_session=my-session
transport=transport-udp

That depends, what do you mean by “unauthed”. How should an incoming call match? Do you want to match based on IP address?

For the example in mind, it would be an internally accessible Asterisk server. So calls would come from a CIDR range. So setting up an CIDR Identify associated with the endpoint would be the way to go?

The identify did the trick. I’ll post my end result below. Thanks for all the help!!!

[transport-udp]
type=transport
bind=0.0.0.0
local_net=10.0.0.0/8
[inbound]
type=endpoint
disallow=all
allow=ulaw
context=inbound
sdp_session=my-session
transport=transport-udp
[inbound-identify]
type=identify
endpoint=inbound
match=10.0.0.0/8,172.0.0.0/8