Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

How can i resolve the issue like when i was trying to receiving the messages from iot hub to devices at the time i was getting receivedMessage as null?

$
0
0

Hi,

I am Working on IoT technology, in one of my project I want scenario like receiving the messages from cloud(IoT hub) to devices, so for that concept I have wrote below lines of code but it will always give null value.

 private static async void ReceiveC2dAsync()
        {
            Debug.WriteLine("\nReceiving cloud to device messages from service");
            while (true)
            {
                Message receivedMessage = await deviceClient.ReceiveAsync();
                if (receivedMessage == null)
                    continue;
                //Console.ForegroundColor = ConsoleColor.Yellow;
                Debug.WriteLine("Received message: {0}", Encoding.ASCII.GetString(receivedMessage.GetBytes()));
                //Debug.ResetColor();
                await deviceClient.CompleteAsync(receivedMessage);
            }
        }

in the above code i was always getting receivedMessage as null.

Please tell me how to resolve this issue.

Regards,

Pradeep


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>