我正在深入研究 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/