Hi,
I am Working on Internet of things, in one of my current project I need to receive the messages from IoT Hub, before I receiving the messages from IoT Hub, first I was sending messages from Two IoT devices to IoT hub. after I was sent messages to IoT hub then I am trying to receive the messages from IoT hub, in this scenario one my IoT device will be turn off, at this time I did not get any messages from IoT hub.
But if two IoT devices are working properly then only I got the messages from IoT Hub.
see the below code.
publicasyncvoid ReceiveDataFromCloud()
{
ServiceBusConnectionStringBuilder builder =newServiceBusConnectionStringBuilder(ConnectionString);
builder.TransportType = ppatierno.AzureSBLite.Messaging.TransportType.Amqp;
factory = MessagingFactory.CreateFromConnectionString(ConnectionString);
client = factory.CreateEventHubClient(eventHubEntity);
group = client.GetDefaultConsumerGroup();
startingDateTimeUtc = DateTime.UtcNow;
for (int i = 0; i <= 0; i++)
{
EventHubReceiver receiver = group.CreateReceiver(i.ToString(), startingDateTimeUtc);
EventData data = receiver.Receive();--à this line of code will give the data value when I connected to one IoT device but when I connected to two IoT devices the data will not give any value just it will stop the debugging.
if (data !=null)
{
var receiveddata =Encoding.UTF8.GetString(data.GetBytes());
var messageString =JsonConvert.DeserializeObject<ConferenceRooms>(receiveddata);
confrooms.Add(messageString);
//var message = new ConferenceRooms(Encoding.ASCII.GetBytes(receiveddata));
Debug.WriteLine("{0} {1} {2}", data.PartitionKey, data.EnqueuedTimeUtc.ToLocalTime(),Encoding.UTF8.GetString(data.GetBytes()));
}
else
{
continue;
}
receiver.Close();
}
client.Close();
factory.Close();
progressring.Visibility = Visibility.Collapsed;
progressring.IsActive = false;
}
Please tell me how to resolve this issue?
Thanks & Regards
G. Pradeep Kumar Reddy