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

NetLeverage
NetLeverage

Teams Direct Routing 503 / 540998 "Service Unavailable - Service state: Inactive/DrainingTransactions"

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). The SBC sends its calls to Microsoft's SIP endpoints, which it finds by looking up three Microsoft host names in DNS. A SIP 503 with Microsoft response code 540998 means the endpoint the SBC used was out of service. One such response now and then is normal. A run of them points to the SBC holding on to an address it should have refreshed, which is what Microsoft's page tells you to check.

The sections below show how to tell a normal event from a repeating fault, how to read what the SBC resolves and at what interval, how to correct that 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 503 page lists the row as "540998 503 Service Unavailable - Service state: Inactive/DrainingTransactions". Its suggested action begins: "This error is expected when Microsoft SIP endpoints are temporarily unavailable for maintenance." It explains that the Microsoft SIP signalling names "point to available endpoints far enough in advance for the SBC to resolve the FQDNs to new endpoints and send traffic to them", so "this error shouldn't occur frequently under the usual circumstances, and no action is required."

The page then gives the action for a repeating error: "If this error occurs frequently, check the SBC configuration to make sure that the SBC resolves the DNS frequently to avoid sending SIP requests to inactive or unavailable Microsoft endpoints. Ideally, DNS resolution should occur every 15 minutes or more often."

The same page lists other 503 rows, and they are not the same fault. The question that separates them is which side said 503.

Row on Microsoft's page Which side Suggested action on the page
540998 503 Service Unavailable - Service state: Inactive/DrainingTransactions A Microsoft SIP endpoint Expected during maintenance; if it repeats, check the SBC resolves DNS every 15 minutes or at a shorter interval
560503 503 Service unavailable. SBC undergoing maintenance or temporarily overloaded The SBC Check the SBC logs for why it returns the 503, make sure the SBC is correctly licensed for the number of concurrent sessions, and determine whether the error relates to a specific destination country or region or calling corridor
10320 503 Bot is unreachable or unable to answer before timeout A bot For a Microsoft bot such as built-in call recording, contact Microsoft Support; for your own or a third-party bot, work with the bot provider

The page applies to Direct Routing PSTN calls only. It does not apply to Microsoft Calling Plan or Operator Connect deployments.

Likely causes

Microsoft's 540998 row gives maintenance as the expected cause and DNS resolution as the cause of a repeating error. Microsoft's plan, SIP protocol and SBC connectivity pages say how the SBC is meant to behave, so the table lists those too.

Cause to check Where Microsoft's pages describe it
A Microsoft SIP endpoint was taken out of service for maintenance The 503 row: expected, no action required
The SBC looks up the Microsoft names at too long an interval and keeps sending to an old address The 503 row: DNS resolution every 15 minutes or at a shorter interval
The SBC sends SIP OPTIONS or calls to specific IP addresses it resolved once instead of to the names The SBC connectivity page: during maintenance or outages the names "might resolve to different IP addresses in another datacenter"
The SBC is not set up with all three Microsoft signalling names The plan page: sip.pstnhub.microsoft.com, sip2.pstnhub.microsoft.com and sip3.pstnhub.microsoft.com, tried in that order
The SBC does not move to the next datacentre when it receives a 503 with a Retry-After header The SIP protocol page, Retry-After
The firewall allows only the addresses DNS returned last time, not the whole Microsoft range The plan page: allow signalling to and from all Microsoft Teams IP ranges

Prove the cause before changing anything

All of these steps only read.

  1. Read the exact text from the SBC log or its SIP trace and confirm the row is 540998 and not 560503. A 560503 comes from the SBC itself, and the routes below do not apply to it.

  2. Count the 540998 responses over a few weeks and write down their times. The page says "If this error occurs frequently". Our own reading: a single response, followed by a call that succeeded through another endpoint, matches Microsoft's description of maintenance, and a response on many days or many times in a day is the repeating case.

  3. Find the SBC's DNS settings for the three Microsoft names and write down how long it keeps an answer before it looks the name up again. Microsoft's target is a lookup every 15 minutes or at a shorter interval.

  4. Check that the SBC's signalling destinations are the three names and not IP addresses. Microsoft's connectivity page says to "Ensure that the SBC is discoverable and configured to send SIP OPTIONS requests only to FQDNs." The three names are, in order:

sip.pstnhub.microsoft.com
sip2.pstnhub.microsoft.com
sip3.pstnhub.microsoft.com
  1. Check what the SBC does on receiving a 503 with a Retry-After header in answer to an INVITE. Microsoft's SIP protocol page says: "If a Direct Routing datacenter is busy, the service can send a Retry-After message with a one-second interval to the SBC", and "the SBC must terminate that connection and try the next available Microsoft datacenter."

  2. Check the firewall rule for signalling. Microsoft's plan page says the names resolve to 52.112.0.0/14 and 52.120.0.0/14, and for IPv6 to 2603:1063:400::/40, and warns: "Configure your SBC and firewall to allow signaling traffic to and from all Microsoft Teams IP ranges, not only the addresses returned from DNS queries."

  3. Look at the SBC in the health dashboard for Direct Routing in the Teams admin center (Voice, Direct Routing). Microsoft's dashboard page shows TLS connectivity status, SIP options status and SBC status. Write down the values and the time they were last checked.

Fix

Choose the route that matches the proof. If the events are isolated, Microsoft's page says no action is required, and none of these routes is needed. All three routes change the SBC or the firewall, not Teams.

Route 1: look up the Microsoft names every 15 minutes or sooner

Write down the SBC's current DNS refresh or cache setting for the Microsoft names, and the time.

Risk: the next step changes how the SBC finds Microsoft's SIP endpoints for every call. Our own advice: change this setting with care, because the SBC's address lookups are used by every call on the trunk.

Microsoft's instruction on the 503 page is "Ideally, DNS resolution should occur every 15 minutes or more often." Set the SBC to resolve sip.pstnhub.microsoft.com, sip2.pstnhub.microsoft.com and sip3.pstnhub.microsoft.com at that interval or shorter.

To undo it: set the SBC's DNS refresh setting back to the value you wrote down.

Route 2: send to the three names, not to addresses

Write down the current signalling destinations and failover order configured on the SBC, and the time.

Risk: the next step changes where the SBC sends signalling and SIP OPTIONS for every call on the trunk. Our own advice: type the names exactly as Microsoft's page gives them.

Microsoft's plan page says the names are tried in priority order, with sip.pstnhub.microsoft.com first, and that if the primary datacentre has an issue the SBC tries sip2.pstnhub.microsoft.com and then sip3.pstnhub.microsoft.com. Replace any fixed addresses with the three names in that order. Microsoft's connectivity page says all three are needed to provide a failover option.

To undo it: put the destination list back as you wrote it down.

Route 3: allow the whole Microsoft signalling range

Write down the current firewall rules that apply to signalling between the SBC and the Microsoft ranges, and the time.

Risk: the next step changes the firewall in front of the SBC. Our own advice: check the range and the direction of each rule before it is saved.

Microsoft's plan page lists the signalling ports: SIP/TLS from the SIP proxy to the SBC, source port 1024 to 65535 and destination port defined on the SBC; and SIP/TLS from the SBC to the SIP proxy, destination port 5061. Allow both directions for 52.112.0.0/14 and 52.120.0.0/14, and for 2603:1063:400::/40 if the SBC uses IPv6.

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

Confirm the fix

  • The SBC's DNS refresh setting shows 15 minutes or less, and the SBC log shows the Microsoft names looked up at that rhythm.
  • Run a test call. It connects, and the SBC log shows no 540998 for it.
  • In the Teams admin center, the SBC's SIP options status reads Active. Microsoft's dashboard page defines that as "The SBC is active. Microsoft Direct Routing service sees the options flowing on a regular interval."
  • Over the next weeks, the count of 540998 responses falls back to occasional single events, which is the pattern Microsoft's page describes as expected.

What to watch afterwards

  • Any 540998 that is followed by a failed call. Microsoft's SIP protocol page says a 503 with a Retry-After header must make the SBC move to the next datacentre, Our own reading: a failed call after one may mean the SBC did not retry.
  • The 560503 row, which comes from the SBC. Microsoft's Set-CsOnlinePSTNGateway reference says that when the -MaxConcurrentSessions parameter is set, the alerting system raises an alert when the concurrent sessions reach 90 percent of that value, and the SBC's licence for concurrent sessions is on Microsoft's checklist for that row.
  • An SBC marked Inactive from time to time. Microsoft's connectivity page ties intermittent Inactive status to SIP OPTIONS being sent to fixed IP addresses rather than names.
  • DNS answers that outlive their time to live. General background on that is in DNS propagation: still the old value after the TTL.
  • Calls that connect but have no audio, which are a media path problem, not a signalling one.

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's page says no action is required for an occasional 540998, and the steps above are for the repeating case. Microsoft supports Direct Routing only with certified devices and says contact the SBC vendor's customer support first.

A change to DNS resolution or to the firewall affects every call on the trunk. Our own advice: make it in a quiet period and keep the record of the old values until a test call has worked.

Sources