We are experiencing errors in the backend when sending iot direct methods, even though we see that the device does receive the direct method call and responds correctly.
From device logs:
28-05-2025 07:37:41.300000: IoT open door command received: [object Object]
From the backend logs:
5/28/2025, 7:37:41.226 AM
Error: Not found at RestApiClient.translateError (/home/site/wwwroot/node_modules/azure-iothub/dist/common-http/rest_api_client.js:282:29) at requestCallback (/home/site/wwwroot/node_modules/azure-iothub/dist/common-http/rest_api_client.js:184:40) at IncomingMessage.<anonymous> (/home/site/wwwroot/node_modules/azure-iothub/dist/common-http/http.js:117:17) at IncomingMessage.emit (node:events:536:35) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { response: <ref *1> IncomingMessage { _events: { close: undefined, error: [Function (anonymous)], data: [Function (anonymous)], end: [Array], readable: undefined }, _readableState: ReadableState { highWaterMark: 16384, buffer: [], bufferIndex: 0, length: 0, pipes: [], awaitDrainWriters: null, [Symbol(kState)]: 194512764 }, _maxListeners: undefined, socket: null, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, rawHeaders: [ 'content-length', '348', 'content-type', 'application/json; charset=utf-8', 'iothub-errorcode', 'DeviceNotOnline', 'date', 'Wed, 28 May 2025 07:37:40 GMT' ], rawTrailers: [], joinDuplicateHeaders: undefined, aborted: false, upgrade: false, url: '', method: null, statusCode: 404, statusMessage: 'Not Found', {\"errorCode\":404103,\"message\":\"The operation failed because the requested device isn't online.
Seems that rebooting the device fixes the issue, but not clear how come the device gets the call but the backend thinks its offline
This is the code that is triggered, really simple
openDoorCommand = function(request, response) {
track('IoT open door command received: ' + request.payload);
metric("remote-open-door",1);
openDoor();
response.send(200, 'Opening door');
}