I was instructed by Alberto Vega (Azure) Microsoft employee in https://social.msdn.microsoft.com/Forums/en-US/73be02e4-d858-4024-af1d-a1b97a69473d/how-to-compile-c-sdk-for-net-461?forum=azureiothub to open an issue here.
It is stated that:
Not expect cancellation to happen in under a minute for any operation.
Use CancellationToken to cancel operations.
This makes it impossible to handle c2d messages for IoT protocols like NB-IoT, LoRaWAN and Sigfox.
In both LoRaWAN and Sigfox, the device sends a message to the cloud, indicating that it is ready to receive a c2d message (called downlink message in Sigfox and LoRaWAN lingo). The cloud infrastructure then has a deadline of about 1 second to check if there are any c2d messages, and transmit them. This deadline is designed to be short, so the device can shut off as soon as possible to conserve battery.
For NB-IoT, there is no standard for the deadline, but due to the high current draw of the NB-IoT modem, a few seconds response time is desirable.
When using the IoT Hub C# SDK, it is (by design?) impossible to check for c2d messages in under 60 seconds because the only way to know that there are no queued messages is to wait until a timeout occurs, and that timeout is at least 60 seconds.
Is IoT Hub the wrong service for this type of devices? If not, how should c2d messages be handled? If we shouldn't use IoT Hub, can we get a recommendation of what else should be used?
Mabe ReceiveAsync could be modified to return null immediately if there are no more queued c2d messages?
@mfalkvidd We will investigate this further and get back to you.
Thanks
Great! Let me know if I can do anything to help clarify the use case.
Another use case that is hard to solve today (to my knowledge):
In a device management web application, I want to be able to list all c2d messages that are queued for a specific device. Currently, the only way to get that list seems to be to wait for the 60 second timeout.
I'll be happy to assist on a Skype call or similar if you want to discuss possible solutions or need additional input.
Would this PR 2 resolve your problem?
@prmathur-microsoft that PR does not seem related, and is 2 years old. Did you reference the wrong PR?
Yes looks like I linked the incorrect PR. [Here ]is the correct PR.
Well, yes. That's why I started the question on the azure iot hub forum with
"I'm in desperate need for https://github.com/Azure/azure-iot-sdk-csharp/pull/1002 which has not been merged yet."
But, according to the answer I got on the azure iot hub forum from _Alberto Vega (Azure) Microsoft employee_
I have reached out internally and the team is still debating about including that PR you are referencing to. They mentioned though that they have been pointing customers to CancellationToken since 1.19 please see the Pull Request 1027 (it has also documentation additions) so you should:
Not expect cancellation to happen in under a minute for any operation. Use CancellationToken to cancel operations.Please open an issue on the SDK repo if you have any further questions.
So I created this issue. We're running around in circles here ;-)
You are right. We are circling around :)
Lets continue the conversation here on github.
I'm very much interested in pulling this PR. However the only reason we are holding that PR is we want to make sure it works for the following scenarios as it would be breaking change if not.
At the moment my team is swamped and we don't have time to look at above three. If you can take care of the three things above then I would be happy to help you with merging this PR.
I'm not sure I'll manage, since I don't have insight in the original PR, but I'll try.
Some questions:
Answers inline -
I guess I should fork this repo, create my own branch, fetch debugerr's branch rebase and push to my branch? Can I then amend PR 1002, or do I need to create a new PR?
How do I run the tests?
_[PM] I am unable to rebase this PR on top of master because of merge conflicts. So if you are not the original author then I believe what you mentioned here is the only option you have. Unless @debugerr is willing to take this forward._
When opening the SDK, Visual Studio code analysis has a lot of complaints. My guess is that Microsoft is using a different ruleset internally. Is this ruleset available somewhere? I looked in CONTRIBUTING.md but didn't find any info.
The code style in this repo is quite different from Visual Studio's default formatting. Is the style guide available somewhere? I wouldn't want to mess up your style, or cause an unnecessary large diff. I looked in CONTRIBUTING.md but didn't find any info.
_[PM] This is a good idea to publish in future. However for now you have to follow https://github.com/Azure/azure-iot-sdk-csharp/blob/master/doc/coding-style.md_
Thank you.
https://github.com/Azure/azure-iot-sdk-csharp/blob/master/doc/coding-style.md says
We have provided a Visual Studio 2013 vssettings file (corefx.vssettings) at the root of the corefx repository, enabling C# auto-formatting conforming to the above guidelines.
But I am unable to find any vssettings file in this repo, and I didn't find such file in https://github.com/dotnet/corefx/find/master either. Do you know where to find this file?
Also, looks like you missed the "How do I run the tests?" question.
@prmathur-microsoft based on the comments from @davilu in https://github.com/Azure/azure-iot-sdk-csharp/pull/1002 that PR does not seem to be a solution. We seem to be back to the orginal question:
Is IoT Hub the wrong service for devices using LoRaWAN, Sigfox and NB-IoT? If not, how should c2d messages be handled? If we shouldn't use IoT Hub, can we get a recommendation of what else should be used?
@mfalkvidd We are currently working on a different approach to fix this issue on AMQP. The idea is to modify ReceiveAsync(TimeSpan timeout) implementation to honor the timeout for the public API by tracking the time for each of the operation that happens before ReceiveMessageAsync call. That should resolve the issue you are facing.
@mfalkvidd We have released Device client v1.21.2 which has fixes around receiveAsync on AMQP. Can you verify if the issue is resolved?
Have not heard back and as the issue is addressed in latest release, closing it. Please reopen if there are more questions.
@mfalkvidd, @prmathur-microsoft, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey