Reputation: 687
This morning I tried to go through Microsoft's tutorial for connecting to an Azure IoT Hub with .NET.
The only differences being the name of my hub, and that I chose the standard S1 pricing tier as I am planning to 'grow' my prototype using this tutorial as a start point.
However when I try to run the console apps, the Receive client throws an error at the following:
var d2cPartitions = eventHubClient.GetRuntimeInformation().PartitionIds;
The full error message is as follows:
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:
My research so far suggests this is some sort of server setup problem, and usually caused by either needing to open ports, change firewall settings, however A) I cant find anywhere in the Azure dashboard to do this B) I would have thought it will be configured correctly for this by default
Is there something obvious that i'm missing, or do I need to go and start chasing my IT department to see if they are blocking it?
Upvotes: 1
Views: 1433
Reputation: 2331
There's no configuration required in the Azure portal to open any ports. However, the Receive Client application in the tutorial needs to have port 5671 open (it communicates with IoT Hub using the AMQP protocol) - it maybe that the firewall configuration on your computer, or your corporate firewall blocks this port.
Upvotes: 1