PS - Lync 2013 Event ID 25051 & 25061 PSTN Gateway Down

Within the Lync server event logs the Event ID 25051 & 25061 errors are logged and PSTN Gateways are marked as down.

EVENT ID 25061

The Mediation Server service has encountered a major connectivity problem with these Trunk peer(s).

Affected PSTN Trunk Service Cluster(s): 
Cause: MEDIATIONSERVER_GATEWAY_OPTIONS_FAILED (Event ID: 25051) was recorded 5 times.  Check other MOM alerts for more details. The MEDIATIONSERVER_GATEWAY_IP_NOT_AVAILABLE (Event ID: 25036), MEDIATIONSERVER_GATEWAY_TLS_NEGOTIATION_FAILED (Event ID: 25040) are examples of events that signal connectivity error conditions with the Trunk peer.
If the failure is MEDIATIONSERVER_GATEWAY_IP_NOT_AVAILABLE (Event ID: 25036), make sure that the correct listening IP and port for the Trunk have been configured in the PSTN Trunk object in management store and that the Trunk is up and running and able to accept incoming connections from the Mediation Server.  If the failure is MEDIATIONSERVER_GATEWAY_TLS_NEGOTIATION_FAILED (Event ID: 25040), make sure that both the Mediation Server and the Trunk are configured for TLS and that the CA for the Trunk's certificate is the trusted certificate path on the Mediation Server and the CA for the Mediation Server's certificate is in the trusted certificate path on the Trunk.

EVENT ID 25051

There was no response from a Trunk to an OPTIONS request sent by the Mediation Server.

The Trunk, x.x.x.x;trunk=x.x.x.x, is not responding to an OPTIONS request sent by the Mediation Server service.
DNS Resolution Failure: False
 Exception: Reason=Other
Microsoft.Rtc.Signaling.MessageParsingException:The operation failed because a message received from the network was not formed properly.
   at Microsoft.Rtc.Signaling.SipAsyncResult2`1.ThrowIfFailed()
   at Microsoft.Rtc.Signaling.SipAsyncResultBase2.EndAsyncOperation[TResult](Object owner, IAsyncResult result)
   at Microsoft.RTC.MediationServerCore.PeriodicOptionsSender.FinishSendOptionMessage(IAsyncResult ar)
Detected at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at Microsoft.Rtc.Signaling.MessageParsingException..ctor(String message, Exception innerException, ParsingFailureReason errorCause, Int32 lineNumber)
   at Microsoft.Rtc.Signaling.MessageParsingException..ctor(String message, Exception innerException, ParsingFailureReason errorCause)
   at Microsoft.Rtc.Signaling.SipTransactionAsyncResult`1.Transaction_ResponseReceived(Object sender, ResponseReceivedEventArgs e)
   at Microsoft.Rtc.Internal.Sip.OutgoingNonInviteTransaction.OnResponseReceived(EventArgs e)
   at Microsoft.Rtc.Internal.Sip.SingleThreadedDispatcherQueue.DispatcherCallback(Object queue)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
Cause: The Mediation Server service cannot communicate with the Trunk Service over SIP due to network connectivity issues.
Please ensure network connectivity and availability of the Trunk for the Mediation Server service to be able to function correctly.Using response Code Translation Rule to prevent Gateway down errors:

This can be caused by Cisco devices and the Inspect SIP option being enabled (can be disabled with "no inspect sip" global setting on the Cisco device.

This can also be caused by NAT and any mediation servers should have a one to one NAT configured.

This can also be caused by SIP Inspection not translating the media address from the internal to the external address and therefore the call will never succeed.

If the problem is due to a gateway intermittently failing to respond you can create a translation rule for the 503 response code and restart mediation service:

New-CsSipResponseCodeTranslationRule -Identity "PstnGateway:x. x.x.x/Rule503" -ReceivedResponseCode 503 -TranslatedResponseCode 483