Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Teams Direct Routing 504 / 549002 "Unable to deliver INVITE: TlsTransport is not connected, State=Disconnected"

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Direct Routing is the Microsoft Teams Phone feature that connects Teams to an organisation's own telephone system through a customer-provided session border controller (SBC). Calls from Teams to the telephone network go out as an INVITE message that Microsoft sends to the SBC over an encrypted TLS connection. A SIP 504 with Microsoft response code 549002 and the words "TlsTransport is not connected" means Microsoft had no working connection to the SBC at the moment it tried to send the call. The fault sits between Microsoft and the SBC.

The sections below show how to read the text that follows "Unable to deliver INVITE", how to check the SBC, its address and port and the firewall, how to correct the cause with a record to undo from, and how to confirm the result. Nothing before the Fix section changes anything.

What the error means

Microsoft's SIP 504 page lists the row as "549002 504 Unable to deliver INVITE: TlsTransport is not connected, State=Disconnected". The suggested action has three parts: "Check whether the Session Border Controller (SBC) is functional. Check whether the SBC is reachable through the specific IP and port. Also, check your firewall settings to make sure that connection to SBC isn't blocked."

The same page carries many 504 rows. The table lists the INVITE rows that need a network, certificate or DNS check, and they are different faults with different fixes, so the first job is to read the exact words. Microsoft's page gives these rows and actions:

Text after "Unable to deliver" Action on Microsoft's page
INVITE: TlsTransport is not connected, State=Disconnected Check the SBC is functional, reachable through the specific IP and port, and not blocked by the firewall
INVITE: No connection could be made because the target machine actively refused it (569002) The same three checks
INVITE: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond (569002) The same three checks
INVITE: outgoing TLS negotiation failed; HRESULT=0x80096004 (569002) The same three checks
INVITE: outgoing TLS negotiation failed; Wrong target principal name configured. HRESULT=0x80090322 CERT_E_WRONG_USAGE (569002) Request a certificate signed by one of the public root certification authorities listed for the SBC
INVITE: TLS decryption failed; HRESULT=590615 (569002) The TLS context has expired; work with the SBC vendor
INVITE: outgoing TLS negotiation failed; HRESULT=0x80090326 (569003) Verify the SBC certificate is signed by a trusted certificate authority and has not expired
INVITE: Outgoing TLS negotiation failed. Remote certificate expired; HRESULT=0x80090328 SEC_E_CERT_EXPIRED (569008) Renew the SBC certificate
INVITE: outgoing TLS negotiation failed; HRESULT=0x80090325 SEC_E_UNTRUSTED_ROOT (569009) Request a certificate signed by a listed root authority and check the TLS profile in use
INVITE: No such host is known (569015) Determine why the SBC's FQDN cannot be resolved through DNS
INVITE/ACK: The requested name is valid, but no data of the requested type was found (569016) Check the DNS record types: A or AAAA

The page applies to Direct Routing PSTN calls only. It does not apply to Microsoft Calling Plan or Operator Connect deployments. Microsoft's health dashboard page gives a SIP 504 response from the SBC as its example of a fault on the SBC side: a response that "indicates an issue on the SBC side and decreases the network effectiveness ratio in the dashboard for this SBC."

Likely causes

Microsoft's 549002 row names three things to check. Microsoft's SBC connectivity, plan and definitions pages say what each one involves.

Cause to check Where Microsoft's pages describe it
The SBC is down or not functional The 504 row: check the SBC is functional
The SBC is not reachable on its public address and signalling port The 504 row: reachable through the specific IP and port
The firewall blocks Microsoft's SIP proxy ranges The 504 row and the plan page: SIP/TLS from the SIP proxy ranges to the SBC's signalling port
The signalling port in Teams does not match the port the SBC listens on The Set-CsOnlinePSTNGateway reference: the SBC's signalling port is set with -SipSignalingPort
The SBC's name resolves to the wrong address The SBC connectivity page: the SBC FQDN must resolve to a public IP address in public DNS
A device between the SBC and Microsoft closed the TLS connection The SBC connectivity page: "One of the intermediary devices (such as a firewall or a router) on the path between the SBC and the Microsoft network might have closed the TLS connection."
The SBC is disabled in Teams The outbound calls page: the gateway's Enabled property must be True

Prove the cause before changing anything

All of these steps only read.

  1. Read the exact text after "Unable to deliver INVITE" from the call record or the SBC log, and match it to the table above. If the text is about a certificate, a host name or a record type, use the row for it and not the checks below. Microsoft's monitoring page says Call Analytics provides standard SIP codes but cannot help when the INVITE was rejected or pairing failed, and that in those cases the SBC logs are the reference.

  2. Check whether the SBC is functional, as Microsoft's row says. Is the SBC process running, and does its own status show the Teams trunk up?

  3. Read how Teams has the SBC configured. Microsoft's outbound calls page gives this read-only command for a Teams PowerShell session. It shows the name, the signalling port, the session limit and whether the gateway is enabled:

Get-CsOnlinePSTNGateway | fl Identity,Fqdn,SipSignalingPort,MaxConcurrentSessions,Enabled

Write down the SipSignalingPort and Enabled values. Microsoft's page says the Enabled value must read True. If it reads False, the gateway is disabled, which Microsoft's page lists as a cause of outbound calls not reaching the SBC.

  1. Compare SipSignalingPort with the port the SBC listens on for Teams. Both values must be the same.

  2. Check that the SBC's name resolves to its public address. Microsoft's connectivity page says to "Verify that the SBC FQDN resolves to a public IP address when queried through public DNS servers." Ask a public DNS resolver, from outside the SBC's network.

  3. Check the firewall rule for signalling. Microsoft's plan page gives the traffic as SIP/TLS from the SIP proxy to the SBC, source port 1024 to 65535 and destination port as defined on the SBC, and from the SBC to the SIP proxy on destination port 5061. The ranges are 52.112.0.0/14 and 52.120.0.0/14, and for IPv6 2603:1063:400::/40. Microsoft adds that inbound SIP traffic to the SBC "can originate from any IPs in these subnets--not only from IPs that resolve from the previously mentioned FQDNs."

  4. Look at the SBC in the health dashboard for Direct Routing in the Teams admin center (Voice, Direct Routing). It shows TLS connectivity status, "TLS connectivity last status" as the time the SBC last made a TLS connection to Direct Routing, SIP options status and SBC status. Microsoft's page says it also warns when a certificate is set to expire within 30 days.

  5. Read the SBC log for the times the TLS connection went down. Microsoft's definitions page describes how the SIP proxy treats connections: a maximum of two TCP/TLS connections per remote FQDN or IP per SIP proxy virtual machine, an idle timeout of two minutes that resets when a SIP transaction occurs, a keep-alive from the SIP proxy that does not reset it, and a CRLF keep-alive sent by the SBC that does.

Fix

Choose the route that matches the proof. Route 1 changes the firewall, Route 2 changes the signalling port in Teams and Route 3 enables a gateway that is switched off.

Route 1: allow SIP/TLS from the Microsoft ranges to the SBC

Write down the current firewall rules that apply to signalling between the SBC and the Microsoft ranges, in the order they are evaluated, and the time.

Risk: the next step changes the firewall in front of the SBC. Allowing a range to reach the SBC's signalling port widens what can reach it, and a mistake in the range, port or direction can block or expose more than intended.

Microsoft's instruction on the 504 page is to "check your firewall settings to make sure that connection to SBC isn't blocked." Allow SIP/TLS in both directions as in the plan page's table: from 52.112.0.0/14 and 52.120.0.0/14 to the SBC's signalling port, and from the SBC to those ranges on port 5061. Add 2603:1063:400::/40 if the SBC uses IPv6.

To undo it: remove the rules you added and put the rule list back in the order you wrote down.

Route 2: set the signalling port in Teams to the port the SBC uses

Write down the current SipSignalingPort value from the read-only command in the proof section, and the time.

Risk: the next command changes the signalling port Direct Routing uses for this SBC, for every call to it. If the new value is wrong, calls to the SBC fail with this same 549002. Our own reading: a port change may also take time to apply. For domain configuration changes, Microsoft's definitions page advises renewing the SBC's connections, or the new configuration "will be applied after the internal SIP proxy cache is renewed – up to four hours."

Microsoft's Set-CsOnlinePSTNGateway reference gives the form with its example port 5064. Run this in a Teams PowerShell session, with your own SBC name and the port the SBC listens on in place of the placeholder:

Set-CsOnlinePSTNGateway -Identity sbc.contoso.com -SipSignalingPort <SBC listening port>

To undo it: run the same command with -SipSignalingPort set to the value you wrote down.

Route 3: enable a gateway that is switched off

Use this route only when the proof showed Enabled reading False. Write down the Enabled value of the gateway from the proof section, and the time.

Risk: the next command turns on the SBC for outbound calls. Microsoft says the Enabled setting is used to temporarily take an SBC out of service during maintenance, so check that nobody disabled it on purpose.

Microsoft's outbound calls page gives this command. Replace the example name with the SBC's name.

Set-CsOnlinePSTNGateway -Identity "sbc2.contoso.com" -Enabled $true

To undo it: run the same command with -Enabled set to the value you wrote down. This takes the SBC out of service for outbound calls.

Rows that need a different fix

If the text names a certificate, a TLS negotiation result, a host name or a record type, Microsoft's page gives a different action for each row, as listed in the first table. Those actions change a certificate, the SBC's TLS context or DNS records. Our own advice: each belongs to the person who owns that item. Microsoft's page says that when an SBC certificate is renewed, the old TLS connections must be closed so the new certificate is used, and that restarting the SBC in a low-traffic window does that.

Confirm the fix

  • Place a test outbound call from Teams to the telephone network. It connects, and the 549002 text no longer appears in the call record or SBC log.
  • Run the Get-CsOnlinePSTNGateway command from the proof section again. Enabled reads True and SipSignalingPort matches the SBC.
  • In the health dashboard, TLS connectivity status shows the connection and "TLS connectivity last status" shows a recent time. Microsoft's page says "If the number of calls is less than 100, the network effectiveness ratio might be low, but still be normal", so judge the ratio on a larger number of calls.

What to watch afterwards

  • Idle connections. Microsoft's definitions page says the SIP proxy's TCP idle timeout is two minutes, and that after two minutes of idling a FIN and ACK are sent to the SBC within about 10 to 20 seconds. A firewall or load balancer that drops idle sessions earlier is covered in connections that drop after a fixed idle time.
  • Connection renewal on the SBC. Microsoft says the SBC "should renew the connection at least once per hour" and must renew all connections when a new SBC certificate is uploaded.
  • An SBC marked Inactive or showing SIP OPTIONS warnings. Microsoft's connectivity page says that status reflects the SIP OPTIONS exchange only, so calls can keep working while it shows.
  • Return paths that differ from the outbound path on the firewall, covered in asymmetric routing and stateful firewalls. General background on a connection that times out is in ERR_CONNECTION_TIMED_OUT in Chrome.

Risks and limits

These steps come from Microsoft's pages and have not been run or lab-tested. They apply to Direct Routing PSTN calls only.

Microsoft supports Direct Routing only with certified devices and says contact the SBC vendor's customer support first.

A firewall change affects every flow it covers, not only voice, and a port change in Teams affects every call to the SBC. Our own advice: make either in a quiet period and keep the record of the old values until a test call has worked.

Sources