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

IoT Hub gives Rejected feedback after calling CompleteAsync()

$
0
0

I'm writing some example code to run on a Raspberry Pi (under Mono running on Raspbian) and communicate with an IoT Hub. I'm using DeviceExplorer to monitor the hub and send messages. I'm using HTTPS transport, as I had trouble with AMQPS.

This is my current receive messages code:


public async void ReceiveMessages()
{
    var pollRate = 180;

    for (;;)
    {
        Message m = await _deviceClient.ReceiveAsync();

        if( m==null)
        {
            _logger.LogDebug(string.Format(@"No message recieved so sleep for {0} seconds", pollRate));
            Thread.Sleep(pollRate*1000);
         }
         else
         {
             var contents = Encoding.UTF8.GetString(m.GetBytes());

             _logger.LogInfo(string.Format(@"Received message contents {0} {1} {2} {3} {4} {5} {6} {7}", contents, m.EnqueuedTimeUtc, m.ExpiryTimeUtc, m.LockToken, m.MessageId, m.SequenceNumber, m.To, m.UserId));

             /*await*/                _deviceClient.CompleteAsync(m);
             //_deviceClient.RejectAsync(m);
         }
    }
}

According to DeviceExplorer the messages are being marked as Rejected:

Started monitoring feedback for device rjwpi.
Sent to Device ID: [rjwpi], Message:"{"msg":"hello7"}", message Id: d15454ac-defa-49b1-af4f-623bc1b5f1bc
Message Feedback status: "Rejected", Description: "Message rejected", Original Message Id: d15454ac-defa-49b1-af4f-623bc1b5f1bc
Has anybody else seen this behaviour?




Viewing all articles
Browse latest Browse all 1916

Trending Articles



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