Azure 中继异常Azure Relay exceptions

本文列出了可能由 Azure 中继 API 生成的一些异常。This article lists some exceptions that might be generated by the Azure Relay APIs. 这些参考信息可随时更改,请不时返回查看更新内容。This reference is subject to change, so check back for updates.

异常类别Exception categories

中继 API 生成的异常可以分为以下类别。The Relay APIs generate exceptions that might fall into the following categories. 此外还列出了解决这些异常应采取的建议操作。Also listed are suggested actions that you can take to help resolve the exceptions.

异常类型Exception types

下表列出了消息异常的类型及其原因,The following table lists messaging exception types and their causes. 并说明可以采取的有助于解决异常的建议性操作。It also notes suggested actions you can take to help resolve the exceptions.

异常类型Exception type 说明Description 建议的操作Suggested action 自动或立即重试注意事项Note on automatic or immediate retry
超时Timeout 服务器在 OperationTimeout 控制的指定时间内未响应请求的操作。The server did not respond to the requested operation within the specified time, which is controlled by OperationTimeout. 服务器可能已完成请求的操作。The server might have completed the requested operation. 这可能是由于网络或其他基础结构延迟造成的。This can happen due to network or other infrastructure delays. 检查系统状态的一致性,并根据需要重试。Check the system state for consistency, and then retry, if necessary. 请参阅 TimeoutExceptionSee TimeoutException. 在某些情况下,重试可能会有帮助;在代码中添加重试逻辑。Retry might help in some cases; add retry logic to code.
操作无效Invalid Operation 不允许在服务器或服务中执行请求的用户操作。The requested user operation is not allowed within the server or service. 有关详细信息,请查看异常消息。See the exception message for details. 检查代码和文档。Check the code and the documentation. 确保请求的操作有效。Make sure that the requested operation is valid. 重试不会解决问题。Retry will not help.
操作已取消Operation Canceled 尝试对已关闭、中止或释放的对象调用某个操作。An attempt is made to invoke an operation on an object that has already been closed, aborted, or disposed. 在极少数的情况下,已释放环境事务。In rare cases, the ambient transaction is already disposed. 检查代码并确保代码不会对已释放的对象调用操作。Check the code and make sure it does not invoke operations on a disposed object. 重试不会解决问题。Retry will not help.
未授权访问Unauthorized Access TokenProvider 对象无法获取令牌,该令牌无效,或者令牌不包含执行操作所需的声明。The TokenProvider object could not acquire a token, the token is invalid, or the token does not contain the claims required to perform the operation. 确保使用正确的值创建令牌提供程序。Make sure that the token provider is created with the correct values. 检查访问控制服务的配置。Check the configuration of the Access Control service. 在某些情况下,重试可能会有帮助;在代码中添加重试逻辑。Retry might help in some cases; add retry logic to code.
参数异常Argument Exception,
参数为 NullArgument Null,
参数超出范围Argument Out Of Range
出现下述一个或多个情况:One or more of the following has occurred:
提供给该方法的一个或多个参数均无效。One or more arguments supplied to the method are invalid.
提供给 NamespaceManagerCreate 的 URI 包含一个或多个路径段。The URI supplied to NamespaceManager or Create contains one or more path segments.
提供给 NamespaceManagerCreate 的 URI 方案无效。The URI scheme supplied to NamespaceManager or Create is invalid.
属性值大于 32 KB。The property value is larger than 32 KB.
检查调用代码并确保参数正确。Check the calling code and make sure the arguments are correct. 重试不会解决问题。Retry will not help.
服务器忙Server Busy 服务目前无法处理请求。Service is not able to process the request at this time. 客户端可以等待一段时间,并重试操作。The client can wait for a period of time, then retry the operation. 客户端可以在特定的时间间隔后重试。The client might retry after a specific interval. 如果重试导致其他异常,请检查该异常的重试行为。If a retry results in a different exception, check the retry behavior of that exception.
超出配额Quota Exceeded 消息实体已达到其最大允许大小。The messaging entity has reached its maximum allowable size. 通过从实体或其子队列接收消息在该实体中创建空间。Create space in the entity by receiving messages from the entity or its subqueues. 请参阅QuotaExceededExceptionSee QuotaExceededException. 如果同时已删除消息,则重试可能会有帮助。Retry might help if messages have been removed in the meantime.
超出消息大小Message Size Exceeded 消息有效负载超出 256 KB 限制。A message payload exceeds the 256-KB limit. 请注意,256 KB 限制是指总消息大小。Note that the 256-KB limit is the total message size. 总消息大小可能包括系统属性和任何 Azure .NET 开销。The total message size can include system properties and any Azure .NET overhead. 减少消息负载的大小,并重试操作。Reduce the size of the message payload, then retry the operation. 重试不会解决问题。Retry will not help.


QuotaExceededException 指示已超出某个特定实体的配额。QuotaExceededException indicates that a quota for a specific entity has been exceeded.

对于中继,此异常包含 System.ServiceModel.QuotaExceededException,指示已超过此终结点的最大侦听器数目。For Relay, this exception wraps the System.ServiceModel.QuotaExceededException, which indicates that the maximum number of listeners has been exceeded for this endpoint. 这会以异常消息的 MaximumListenersPerEndpoint 值表示。This is indicated in the MaximumListenersPerEndpoint value of the exception message.


TimeoutException 指示用户启动的操作所用的时间超过操作超时值。A TimeoutException indicates that a user-initiated operation is taking longer than the operation timeout.

检查 ServicePointManager.DefaultConnectionLimit 属性的值。Check the value of the ServicePointManager.DefaultConnectionLimit property. 达到此限制也可能导致 TimeoutExceptionReaching this limit also can cause a TimeoutException.

对于中继,可能会在第一次打开中继发送方连接时收到超时异常。For Relay, you might receive timeout exceptions when you first open a relay sender connection. 此异常有两个常见的原因:There are two common causes for this exception:

  • OpenTimeout 值可能太小(甚至只有几分之一秒)。The OpenTimeout value might be too small (if even by a fraction of a second).
  • 本地中继侦听器可能无响应(或者可能遇到禁止侦听器接受新客户端连接的防火墙规则问题),而 OpenTimeout 值约小于 20 秒。An on-premises relay listener might be unresponsive (or it might encounter firewall rules issues that prohibit listeners from accepting new client connections), and the OpenTimeout value is less than about 20 seconds.


'System.TimeoutException': The operation did not complete within the allotted timeout of 00:00:10.
The time allotted to this operation may have been a portion of a longer timeout.

常见原因Common causes

此错误有两个常见的原因:There are two common causes for this error:

  • 配置不正确Incorrect configuration

    运行条件下的操作超时值可能太小。The operation timeout might be too small for the operational condition. 客户端 SDK 的操作超时默认值为 60 秒。The default value for the operation timeout in the client SDK is 60 seconds. 请查看代码中的值是否设置过小。Check to see whether the value in your code is set to something too small. 请注意,CPU 使用率和网络条件可能会影响操作完成时间。Note that CPU usage and the condition of the network can affect the time it takes for an operation to complete. 最好是不要将操作超时设置为很小的值。It's a good idea not to set the operation timeout to a very small value.

  • 临时服务错误Transient service error

    有时,中继服务在处理请求时可能会遇到延迟。Occasionally, the Relay service might experience delays in processing requests. 例如,在流量高峰时段可能会发生这种情况。This might happen, for example, during periods of high traffic. 如果发生这种情况,可以在延迟后重试操作,直到操作成功为止。If this occurs, retry your operation after a delay, until the operation is successful. 如果多次尝试同一操作后仍然失败,请访问 Azure 服务状态站点,看是否有已知的服务中断。If the same operation continues to fail after multiple attempts, check the Azure service status site to see if there are known service outages.

后续步骤Next steps