询问者
关于AZURE Iot Hub官网demo运行的问题

问题
-
我从官网上下载的Iot hub demo,用的vs2015,但是运行起来总是有问题,显示的是:系统检测到在一个调用中尝试使用指针参数时的无效指针地址。有没有哪位遇到类似的情况,异常如下,代码如下
exception:
Microsoft.ServiceBus.Messaging.MessagingCommunicationException was unhandled
HResult=-2146233088
IsTransient=true
Message=系统检测到在一个调用中尝试使用指针参数时的无效指针地址。
Source=Microsoft.ServiceBus
StackTrace:
在 Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
在 Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.RunSynchronously()
在 Microsoft.ServiceBus.Messaging.Amqp.AmqpEventHubClient.GetRuntimeInformation()
在 ReadDeviceToCloudMessages04.Program.Main(String[] args) 位置 F:\学习课件\C#学习资料\AZURE练习程序\ReadDeviceToCloudMessages\ReadDeviceToCloudMessages04\Program.cs:行号 34
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
ErrorCode=10014
HResult=-2147467259
Message=系统检测到在一个调用中尝试使用指针参数时的无效指针地址。
NativeErrorCode=10014
Source=Microsoft.ServiceBus
StackTrace:
Server stack trace:
在 System.Net.Sockets.Socket.get_RemoteEndPoint()
在 Microsoft.ServiceBus.Messaging.Amqp.Transport.TcpTransport..ctor(Socket socket, TcpTransportSettings transportSettings)
在 Microsoft.ServiceBus.Messaging.Amqp.Transport.TcpTransportInitiator.Complete(SocketAsyncEventArgs e, Boolean completeSynchronously)
Exception rethrown at [0]:
在 Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
在 Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.<GetAsyncSteps>b__9e(ConnectAsyncResult thisPtr, IAsyncResult r)
在 Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [1]:
在 Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
在 Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.EndCreateConnection(IAsyncResult result)
在 Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.CreateAsyncResult.<GetAsyncSteps>b__4(CreateAsyncResult thisPtr, IAsyncResult r)
在 Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [2]:
在 Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
在 Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
在 Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
在 Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
在 Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.CreateManagementLinkAsyncResult.<>c__DisplayClass17a.<GetAsyncSteps>b__175(CreateManagementLinkAsyncResult thisPtr, IAsyncResult r)
在 Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [3]:
在 Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
在 Microsoft.ServiceBus.Messaging.Amqp.AmqpEventHubClient.GetRuntimeInfoAsyncResult.<GetAsyncSteps>b__14(GetRuntimeInfoAsyncResult thisPtr, IAsyncResult r)
在 Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
InnerException:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.ServiceBus.Messaging; using System.Threading; namespace ReadDeviceToCloudMessages04 { class Program { static string connectionString = "xxxxx"; static string iotHubD2cEndpoint = "messages/events"; static EventHubClient eventHubClient; private static async Task ReceiveMessagesFromDeviceAsync(string partition, CancellationToken ct) { var eventHubReceiver = eventHubClient.GetDefaultConsumerGroup().CreateReceiver(partition, DateTime.UtcNow); while (true) { if (ct.IsCancellationRequested) break; EventData eventData = await eventHubReceiver.ReceiveAsync(); if (eventData == null) continue; string data = Encoding.UTF8.GetString(eventData.GetBytes()); Console.WriteLine("Message received. Partition: {0} Data: '{1}'", partition, data); } } static void Main(string[] args) { Console.WriteLine("Receive messages. Ctrl-C to exit.\n"); eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, iotHubD2cEndpoint); // var d2cPartitionss = eventHubClient.GetRuntimeInformation(); var r = eventHubClient.GetRuntimeInformation().PartitionIds; var d2cPartitions = eventHubClient.GetRuntimeInformation().PartitionIds; CancellationTokenSource cts = new CancellationTokenSource(); System.Console.CancelKeyPress += (s, e) => { e.Cancel = true; cts.Cancel(); Console.WriteLine("Exiting..."); }; var tasks = new List<Task>(); foreach (string partition in d2cPartitions) { tasks.Add(ReceiveMessagesFromDeviceAsync(partition, cts.Token)); } Task.WaitAll(tasks.ToArray()); } } }
全部回复
-
你好,
是不是发送的消息大小超过了设置。
请参考以下的内容:
Keep Fighting
-
你好 进击小硕,
MessagingCommunicationException指的是无法和service bus建立连接。下面的链接 Service Bus messaging exceptions 罗列了一些产生这个error的场景,请看一下。所以我认为有可能是云端的Service Bus没有正确配置或者代码里面的链接地址写错了。你能测试一下或者提供更多详细信息吗?
另外,如果您使用的是中国区的Azure的话,请注意要修改成中国区的地址。https://servicebusname.servicebus.chinacloudapi.cn/eventhubname
希望能够帮到你。We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
Hi,
您是从国际版Azure Code Sample页面下载的code测试的吗?国际版关于IoT一共有11个示例,可否告诉具体是哪一个示例,下面是示例的地址:https://azure.microsoft.com/en-us/documentation/samples/?service=iot-hub。如果是其他的示例请提供地址以方便进行测试。也请提供您所遇到异常的操作步骤以方便还原并找出问题。
Best Regards,
Jambor
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
前几天一直在纠结azure官网的demo调试问题,只要调用EVenthub类就会提示是调用一个无效指针,之后昨天调试发现可以运行了,但是今天又不能运行,后来发现换了台电脑再试程序可以运行,所以我初步判断应该是电脑上的软件或者防火墙拦截问题。但是我吧所有防火墙以及360杀毒软件都关掉,还是不能运行,大家有没有碰到之类的问题?求解
- 已合并 Jambor yaoMicrosoft employee, Moderator 2016年5月16日 8:06 相同主题
-
Hi,
请尝试开启5671 /9352 端口,看看是否能够有所帮助。
Regards
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.