So recently I had a problem with Enterprise Voice at a customer side, they had Lync 2013 Enterprise Pool consist of 2 Frontend, collocating mediation server on the same machines.

Customer have Audiocodes gateway added to the topology and one Trunk created to the Lync Mediation pool, all Dial plans, Voice policies, PSTN usage and routing were configured correct.

But they could not make any PSTN outbound or inbound calls from and to Lync.

The Problem

So I asked for recreation of the problem to take a look at the Lync SIP stack logs (my favorite thing to do 🙂 ), and the call immediately failed, opening it with snooper I saw in the call flow error

“503 Service Unavailable”

So looking for the error details it said “Gateway did not respond in a timely manner (timeout)” but I also noticed that the value of “ms-trunking-peer” is an IP, not a FQDN of the Audiocodes gateway which will cause problem if you using TLS between Lync and the gateway.

So I had feedback from them that they are using TLS between the Lync and Audiocodes, so I logged into the Frontend server mentioned in the error, started Event viewer and found LS Mediation 25051 error logged 5 times and followed by LS Mediation 25061.

The LS Mediation 25051 is error registered for OPTION request sip message for TLS negotiation, and after 5 tries Mediation server logs LS Mediation server 25061 and mark gateway as down.

Reading the first line of the error, I can see the problem, “The Target Principal name is incorrect” , which indicating a problem with the SSL Certificate installed on the Audiocodes gateway.

Opened Lync Topology, downloaded the topology and found out that under PSTN gateway the Audiocodes is defined by the IP address not by using the FQDN configured on it and used to issue the Certificate from the internal CA of the Infrastructure, which can work if you using TCP between Lync and Gateway not TLS (not recommended by me)

LS Mediation Server 25051

LS Mediation Server 25061


So the solution was simple, after making sure that the Audiocodes had the correct SSL Certificate installed and taking a note of its FQDN,

· I removed the gateway from the Route under Voice routing setting in the Lync Control panel, otherwise I won’t be able to remove the gateway from the Topology

· Removed the PSTN gateway from the topology

· Published the topology

· Re added the Audiocodes but using it’s FQDN this time

· Created a new trunk

· Published the topology

· Back on the Lync Control Panel, I opened Voice routing >> Routes and added the new PSTN gateway / trunk to it.

Making a test call, it worked 🙂

So here you go…