Azure IoT 中心基本接收示例,AMQP 错误

标签 azure amqp azure-iot-hub

我正在深入研究 azure 物联网集线器和工作连接技术,使用此处找到的教程:https://azure.microsoft.com/nl-nl/documentation/articles/iot-hub-csharp-csharp-getstarted/

运行接收器示例时(本文这一部分:https://azure.microsoft.com/nl-nl/documentation/articles/iot-hub-csharp-csharp-getstarted/#receive-device-to-cloud-messages)

我收到一条错误消息:

var d2cPartitions = eventHubClient.GetRuntimeInformation().PartitionIds;

我收到此错误(完整的错误日志位于底部):

Message=An AMQP error occurred (condition='amqp:link:redirect').

我找不到导致此问题的原因,因为我使用了一个基本示例,并且我的集线器显示配置正确。顺便说一句,发送工作正常。 有人有想法吗?

完整的错误日志:

Microsoft.ServiceBus.Messaging.MessagingException was unhandled
  HResult=-2146233088
  IsTransient=true
  Message=An AMQP error occurred (condition='amqp:link:redirect').
  Source=Microsoft.ServiceBus
  StackTrace:
Server stack trace: 
Exception rethrown at [0]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.AmqpClient.AmqpManagementLink.EndCreateManagementLink(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.CreateAsyncResult.<GetAsyncSteps>b__4(CreateAsyncResult thisPtr, IAsyncResult r)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [1]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.AmqpClient.AmqpManagementLink.AmqpManagementOperationAsyncResult`1.<GetAsyncSteps>b__21(T thisPtr, IAsyncResult r)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [2]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Amqp.AmqpEventHubClient.GetRuntimeInfoAsyncResult.<GetAsyncSteps>b__18(GetRuntimeInfoAsyncResult thisPtr, IAsyncResult r)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [3]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.RunSynchronously()
   at Microsoft.ServiceBus.Messaging.Amqp.AmqpEventHubClient.GetRuntimeInformation()
   at ReadDeviceToCloudMessages.Program.Main(String[] args) in C:\Users\tmartena\documents\visual studio 2015\Projects\azureTestDevice\ReadDeviceToCloudMessages\Program.cs:line 21
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:

最佳答案

您的问题来自您的企业代理。 通过将服务总线环境通信模式设置为 HTTP,您可以轻松定义 EventHubClient 的代理。 在你的 c# 中添加:

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

然后在您的 app.config 文件中添加:

 <system.net>
    <defaultProxy>
      <proxy bypassonlocal="True" proxyaddress="http://proxyadress:port" />
    </defaultProxy>
  </system.net>

希望对你有帮助

关于Azure IoT 中心基本接收示例,AMQP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35319395/

相关文章:

c# - 在没有 Redis 的 Azure 上运行的 ASP.NET Core 应用程序中缓存数据

azure - 根据 Azure SQL 数据库的数据中心转换连接字符串

spring - Spring AMQP 相对于 RabbitMQ Java 客户端有什么优势吗?

java - JMS 客户端确认模式下的保证交付如何工作?

将数据推送到 Cosmos DB 时 Azure 流分析作业降级

azure - 当设备在未在 IoT 中心注册的情况下发送遥测消息时,IoT 中心会发生什么行为?

java - 使用 Java 将 Redis 数据库连接到 Azure 云

c# - 如何停止Azure Durable函数上的并行执行?

java - JMS 和 AMQP - RabbitMQ

azure - 如何在Azure函数中获取由IOThub消息触发的消息的deviceid