问题描述
我正在使用此处提供的教程来研究Azure的Iot集线器和连接的技术,以供参考: https://azure.microsoft.com/nl-nl/documentation/articles/iot-hub-csharp-csharp-getstarted/
I'm delving into azure Iot hubs and connected technologie for work, using the tutorial found here: 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-云消息)
When running the receiver example (this section of the article: https://azure.microsoft.com/nl-nl/documentation/articles/iot-hub-csharp-csharp-getstarted/#receive-device-to-cloud-messages)
我在网上遇到错误:
var d2cPartitions = eventHubClient.GetRuntimeInformation().PartitionIds;
我收到此错误(底部有完整的错误日志):
I get this error (complete error log at the bottom):
Message=An AMQP error occurred (condition='amqp:link:redirect').
由于我使用了一个基本示例,所以我找不到导致此情况的原因,并且我的集线器似乎配置正确.顺便说一句发送正常.有人知道吗?
I cannot find what causes this, since I use a basic example, and my hub appears rightly configured. Sending works fine btw.Anyone got an idea?
完整的错误日志:
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#中添加以下内容:
Your issue comes from your enterprise proxy.You can easily define a proxy to EventHubClient by setting the Service Bus environnement communication mode to HTTP.In your c# add this :
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;
然后在您的app.config文件中添加:
then in your app.config file add :
<system.net>
<defaultProxy>
<proxy bypassonlocal="True" proxyaddress="http://proxyadress:port" />
</defaultProxy>
</system.net>
希望有帮助
这篇关于Azure IoT中心基本接收示例,AMQP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!