Open don opened 8 years ago
@don do you have an example sketch to reproduce the issue? I can look into getting Azure credentials if needed.
@sandeepmistry Try this sketch https://github.com/don/MKR1000-Azure/blob/master/MKR1000-Azure.ino
It's not using the RestClient but it has the same problem where it fails without the delay. I set the delay to 200 https://github.com/don/MKR1000-Azure/blob/master/MKR1000-Azure.ino#L144 here for more consistent results.
The example code is using some demo API keys, so it should work for a while. If not email me and I'll generate some keys for you.
@don thank you for providing the example. I think the following lines: https://github.com/don/MKR1000-Azure/blob/master/MKR1000-Azure.ino#L80-L84 need to be changed to the following:
int c;
while (client.available() || client.connected()) {
c = client.read();
if (c != -1) {
response.concat((char)c);
}
}
then the delay can be removed in your sketch. Without a check for client.connected()
, data might not be available right after sending, so client.available()
will be zero.
Do you also have an example for the original issue, where use of the RestClient was failing? It has a check for connected()
so is probably a different issue.
I've submitted #9 to resolve this. The root cause of this issue is RestClient::RestClient(Client& netClient, const char* _host, int _port)
not initializing the value of timeout
so it is set to 0.
When posting data to Azure IoT from a MKR1000, I'm getting status of 0.
If I increase the delay to 150, it works every time and I get the expected
204 No Content
response.https://github.com/arduino-libraries/RestClient/blob/da79137b4441a0c2eebe71f60b6d4a631da01fbe/RestClient.cpp#L103-L105
What's the right way to fix this?