【问题标题】:Azure IoT hub basic receiving example, AMQP errorAzure IoT hub 基本接收示例,AMQP 错误
【发布时间】:2016-02-10 15:34:53
【问题描述】:

我正在研究 azure IoT hubs 和连接技术,使用此处找到的教程: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:

【问题讨论】:

    标签: azure amqp azure-iot-hub


    【解决方案1】:

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

    ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;
    

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

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

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      好吧,这很奇怪。这自己解决了。发布后我回家了,测试发送和接收程序都很好。 (是的,为了安全起见,我确实重新启动了它们)

      原因?不知道。或许每天对集线器的清理解决了它,但还是很奇怪。

      如果有人遇到此问题并有明确的原因和解决方案,请务必将其作为答案。如果这可能再次发生,可能需要它。

      可能的原因是端口关闭或代理服务器不允许程序请求通过。我在家里试过了,没有代理,效果很好。 因此,如果您遇到此问题,请在其他位置尝试。

      【讨论】:

      • 您在工作中是否有访问 Internet 的代理?这是我的问题。我不知道如何告诉 EventHubClient 给你 http 而不是 amqp 协议...
      • @Zordid 是的,我们已经调查过了,这实际上似乎是问题所在。它在家里工作得很好,但在工作中却不行。所以它要么是封闭的端口,要么是代理设置。编辑了我的答案以包含此内容。
      猜你喜欢
      • 2016-06-13
      • 2017-08-24
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多