Azure IoT 中心 - 无法建立连接,因为目标机器主动拒绝它
Azure IoT Hub - No connection could be made because the target machine actively refused it
今天早上我试着浏览了微软的
tutorial for connecting to an Azure IoT Hub with .NET.
唯一的区别是我的集线器的名称,我选择了标准的 S1 定价层,因为我计划'grow'我的原型使用本教程作为起点。
然而,当我尝试 运行 控制台应用程序时,接收客户端在以下位置抛出错误:
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 部门,看看他们是否阻止了它?
无需在 Azure 门户中进行配置即可打开任何端口。但是,本教程中的 Receive Client 应用程序需要打开端口 5671(它使用 AMQP 协议与 IoT 中心通信)——可能是您计算机上的防火墙配置或您的公司防火墙阻止了此端口。
今天早上我试着浏览了微软的 tutorial for connecting to an Azure IoT Hub with .NET.
唯一的区别是我的集线器的名称,我选择了标准的 S1 定价层,因为我计划'grow'我的原型使用本教程作为起点。
然而,当我尝试 运行 控制台应用程序时,接收客户端在以下位置抛出错误:
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 部门,看看他们是否阻止了它?
无需在 Azure 门户中进行配置即可打开任何端口。但是,本教程中的 Receive Client 应用程序需要打开端口 5671(它使用 AMQP 协议与 IoT 中心通信)——可能是您计算机上的防火墙配置或您的公司防火墙阻止了此端口。