How to fix Error 13162 on Windows Server 2025 / Windows 11

Why This Error Happens

Error 13162 occurs within SQL Server’s Service Broker architecture when a conversation endpoint enters an error state that cannot be resolved through normal message exchange, forcing the engine to terminate it using the WITH CLEANUP option. This typically happens because the corresponding dialog on the remote endpoint has already been dropped, the message payload failed contract validation, or the sys.conversation_endpoints catalog view contains orphaned entries due to a crashed transaction. In Windows Server 2025 / Windows 11 environments, this is frequently exacerbated by antivirus or Windows Defender real-time scanning interfering with the .mdf/.ldf I/O operations that Service Broker relies on for transactional consistency.

Step-by-Step Resolution Guide

Step 1: Identify the Orphaned Conversation Handles

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following query to locate endpoints stuck in an error state:
SELECT conversation_handle, far_service, state_desc, lifetime 
FROM sys.conversation_endpoints 
WHERE state_desc = 'ERROR';
  • Note the conversation_handle GUIDs returned; these are the sessions causing the 13162 event log entries.

Step 2: Force-Terminate the Problematic Dialogs

  • For each handle identified in Step 1, execute a manual cleanup command to clear the queue:
END CONVERSATION 'handle-guid-here' WITH CLEANUP;
  • If the command hangs, verify no active transactions are locking the sys.transmission_queue by checking sys.dm_tran_locks.
  • Run DBCC CHECKDB on the specific database if cleanup fails repeatedly, as this often indicates underlying page corruption on the system tables.

Step 3: Adjust Windows Server Exclusions and Service Broker Settings

  • Navigate to Windows Security > Virus & threat protection > Manage settings > Add or remove exclusions.
  • Add the SQL Server data directory (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA) to prevent I/O locks during the conversation handshake.
  • Restart the SQL Server Service Broker dependency by restarting the SQL Server service via services.msc to flush the transmission queue.

Step 4: Validate Network Timeout Configurations

  • Check the Dialog Timer settings within your Service Broker queue to ensure timeouts are not too aggressive for the network latency in Windows Server 2025 virtualized environments.
  • Update the QUEUE definition to include ACTIVATION procedures that handle Error message types gracefully to prevent future forced cleanups.

Alternative or Verification Steps

  • Verify the fix by re-running the sys.conversation_endpoints query from Step 1; the result set should return zero rows with state_desc = 'ERROR'.
  • If the issue persists across reboots, check the SQL Server Error Log for Event ID 9675, which often precedes 13162 and points to a specific certificate or encryption mismatch between the initiator and target databases.