Azure IoT Hub - 无法建立连接,因为目标计算机主动拒绝它

时间:2018-03-12 13:42:23

标签: c# azure-iot-hub

今天早上我试图通过微软 tutorial for connecting to an Azure IoT Hub with .NET.

唯一的区别是我的中心名称,我选择了标准的S1定价等级,因为我计划“成长”。我的原型使用本教程作为起点。

但是,当我尝试运行控制台应用程序时,接收客户端会在以下位置引发错误:

var d2cPartitions = eventHubClient.GetRuntimeInformation().PartitionIds; 

完整的错误消息如下:

  Microsoft.ServiceBus.Messaging.MessagingCommunicationException was unhandled
  HResult=-2146233088
  IsTransient=true
  Message=An error occurred during communication with 'DeviceGateway_{auto generated alphanumeric string here}:iothub-ns-{auto generated connection details here}.servicebus.windows.net:5671'. Check the connection information, then retry.
  Source=Microsoft.ServiceBus
  StackTrace:
       at Microsoft.ServiceBus.Common.ExceptionExtensions.ThrowException(Exception exception)
       at Microsoft.ServiceBus.Common.ExceptionExtensions.Rethrow(Exception exception)
       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 R:\SRE_Prototypes\IoTHubGetStarted\ReadDeviceToCloudMessages\Program.cs:line 22
       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: 
       ErrorCode=10061
       HResult=-2147467259
       Message=No connection could be made because the target machine actively refused it
       NativeErrorCode=10061
       Source=mscorlib
       StackTrace:
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at Microsoft.ServiceBus.Common.ExceptionExtensions.Rethrow(Exception exception)
            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.Amqp.Transport.AmqpTransportInitiator.ConnectAsyncResult.End(IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.Amqp.Transport.AmqpTransportInitiator.EndConnect(IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.<>c.<GetAsyncSteps>b__13_3(ConnectAsyncResult thisPtr, IAsyncResult r)
            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
         --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at Microsoft.ServiceBus.Common.ExceptionExtensions.Rethrow(Exception exception)
            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.End(IAsyncResult result, ConnectInfo& info)
            at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.RedirectConnectionManager.OnEndCreateInstance(IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.SingletonDictionaryManager`2.LoadInstanceAsyncResult.<>c.<GetAsyncSteps>b__13_3(LoadInstanceAsyncResult thisPtr, IAsyncResult r)
            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
         --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at Microsoft.ServiceBus.Common.ExceptionExtensions.Rethrow(Exception exception)
            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
            at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
            at Microsoft.ServiceBus.Messaging.SingletonDictionaryManager`2.LoadInstanceAsyncResult.End(IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.SingletonDictionaryManager`2.EndLoadInstance(IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.RedirectConnectionManager.EndGetConnection(IAsyncResult result)
            at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.OpenLinkAsyncResult.<>c.<GetAsyncSteps>b__35_11(OpenLinkAsyncResult thisPtr, IAsyncResult r)
            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
       InnerException: 

到目前为止,我的研究表明这是某种服务器设置问题,通常是由于需要打开端口,更改防火墙设置而引起的 A)我无法在Azure仪表板中的任何位置找到这样做 B)我原本认为默认情况下会正确配置

是否有一些明显缺失的东西,或者我是否需要开始追逐我的IT部门以确定他们是否阻止了它?

1 个答案:

答案 0 :(得分:1)

Azure门户中无需配置即可打开任何端口。但是,教程中的Receive Client应用程序需要打开端口5671(它使用AMQP协议与IoT Hub通信) - 可能是您计算机上的防火墙配置或公司防火墙阻止此端口。