PJSIP Switches Transport from UDP to TLS on Re-Invite

I have a signaling issue with PJSIP. Here is my setup:

Flowroute DID → Asterisk 16.17.0 Server → ATA registered to Asterisk

I’m using PJSIP on both legs of the call (I have a Flowroute endpoint and an ATA endpoint in pjsip.conf)

If I call the DID from my cell phone and then I hang up the cell phone, neither the Asterisk server nor the ATA sees the hangup. I don’t have the issue with chan_sip but I do have the issue with I use chan_pjsip.

It took me a while, but I’m pretty sure I tracked the issue down. I’m doing direct media, and as expected, when the ATA answers Asterisk sends a re-invite and then the media goes direct. However, the re-invite is switching the transport from port 5062/udp to port 5061/TLS.

I can’t use TLS in this scenario, but I can’t figure out how to stop that from happening. Here’s what I’ve tried:

  • I created a new transport for port 5062 tcp, but that didn’t help.
  • I tried setting disable_tcp_switch=yes in pjsip.conf but that didn’t help either.
  • I tried setting symmetric_transport=yes on the UDP port 5062 transport, but that didn’t help.

Can someone please tell me how I can either keep everything on port 5062/udp or at least avoid using TLS? I use TLS with Flowroute for other purposes (hence why I have a TLS transport) but I just can’t use it here.

I’ve uploaded some scrubbed logs.
tls switch.txt (5.7 KB)

Do you have an explicit transport set on the endpoint configuration in question? If so is that transport TLS based?

See wiki about how transport are selected for more information, and to rule things out.

That was it. I did have an explicit transport set on my flowroute endpoint. I removed that, and everything seems to be working fine now - the calls that come in as TLS stay TLS, and the calls come in as UDP stay UDP.

I’m still learning PJSIP (clearly). I thought you had to define a transport for each endpoint, but the article you linked me to shows that’s not true, and in my case, was problematic. Thanks for your help!