Direct method always return {"status:500", "payload":null} result on invocation on Raspberry pi 3
See original GitHub issueI am referring to the https://github.com/Azure/azure-iot-sdk-node/blob/master/device/samples/simple_sample_module_method.js
link. This is my app.js:
'use strict';
var Transport = require('azure-iot-device-mqtt').Mqtt;
var Client = require('azure-iot-device').ModuleClient;
var Message = require('azure-iot-device').Message;
Client.fromEnvironment(Transport, function (err, client)
{
if (err)
{
throw err;
}
else
{
client.on('error', function (err)
{
throw err;
});
// connect to the Edge instance
client.open(function (err)
{
if (err)
{
throw err;
} else
{
console.log('IoT Hub module client initialized');
// Act on input messages to the module.
client.on('inputMessage', function (inputName, msg)
{
pipeMessage(client, inputName, msg);
});
client.onMethod('getdevices', function(request,response)
{
console.log('getdevices called');
if(request.payload)
{
console.log('Payload:');
console.dir(request.payload);
}
var responseBody =
{
message: 'list of all devices.'
};
response.send(200, responseBody, function(err)
{
if (err)
{
console.log('failed sending method response: ' + err);
}
else
{
console.log('successfully sent method response');
}
});
});
}
});
}
});
// This function just pipes the messages without any change.
function pipeMessage(client, inputName, msg) {
client.complete(msg, printResultFor('Receiving message'));
if (inputName === 'input1') {
var message = msg.getBytes().toString('utf8');
if (message) {
var outputMsg = new Message(message);
client.sendOutputEvent('output1', outputMsg, printResultFor('Sending received message'));
}
}
}
// Helper function to print results in the console
function printResultFor(op) {
return function printResult(err, res) {
if (err) {
console.log(op + ' error: ' + err.toString());
}
if (res) {
console.log(op + ' status: ' + res.constructor.name);
}
};
}
The docker images for the same is: gaurav28/nodedb:0.0.1-arm32v7 running on Raspbian Stretch Raspberry pi 3 Model B+
Whenever I try to invoke my function, I get the same response
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (5 by maintainers)
Top Results From Across the Web
Getting http 500 error on raspberry pi
I have installed Raspbian on RPi 3. apache2, php5, wiring Pi library. When I was trying to open php file from browser I...
Read more >Direct Messages fail with Status: 501 Payload: Null
"Equivalent to HTTP status code 501, not implemented server error. It is used when a method call from the service specifies a method...
Read more >Bug #1861936 “Raspberry Pi 3 network dies shortly after a ...
Raspberry Pi 3 network partially dies (transmission doesn't work, reception still does) shortly after a burst of network load over IPv6, ...
Read more >Understand Azure IoT Hub direct methods
This article describes how to use direct methods to invoke code on your devices from a service app.
Read more >How to use interrupts with Python on the Raspberry Pi ...
The best way to get the latest RPi.GPIO (currently 0.5.5) is to flash a new SD card with the latest NOOBS or Raspbian....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gauravagarwal28 it should not matter if the modules are referenced from Dockerhub or ACR as the exact same deployment produced a working response on AMD64 but failed only on ARM32. This also allows the attached sample code to be reproducible by others without ACR credentials. It appears that this issue is isolated to ARM32 platforms and that both JS and C# modules are producing the same error response on attempts to invoke Direct Methods.
@varunpuranik could you post the module code that you used which allowed you to invoke a DirectMethod on the Pi? I am getting the same response
{"status":500,"payload":null}
whether I use a JS or C# module. As soon as I deploy the exact same code to an AMD64 device I get a properstatus:200
response. Both devices are hard-wired to the same router. This looks like an issue with the ARM32 runtime on my end.@gauravagarwal28 , I have noticed this exact same issue on ARM devices using very similar code. I am suspicious that direct methods do not work in the ARM SDKs.
My experience with this issue is documented @ https://github.com/Azure/iotedge/issues/98#issuecomment-415836594