Azure / Azure/azure-iot-sdk-node

SDK Send Events not working or erroring

Open
#1,227 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
268
Forks
228
PR merge metrics
No merged PRs in 30d

Description

OS and version used: Windows 11
Node.js version: 22.11.0, Deno v2.0.6
npm version: 10.9.0
list of installed packages: N/A
Version: Deno 2.0.6

When using the Node SDK in Deno to attempt to sent events and batch events to the cloud, my callback function is not getting called, no error is thrown and no messages are going through. Example code below:

import { Client, Message} from 'npm:azure-iot-device@1.18.3';
import { clientFromConnectionString } from 'npm:azure-iot-device-http';
import '@std/dotenv/load';

const deviceConnectionString: string = Deno.env.get('IOTHUB_DEVICE_CONNECTION_STRING')!;

const { DeviceID, HostName, SharedAccessKey } = parseConnectionString(
deviceConnectionString,
);
const client: Client = clientFromConnectionString(deviceConnectionString);

try {
client.sendEvent(new Message('some data from my device'), printResultFor("send"));
} catch (error) {
console.log(error);
}

function printResultFor(op: any): (err: any, res: any) => void {
return function printResult(err: any, res: any): void {
try {
if (err) console.log('Failed to send message with status ' + op + ' error: ' + err.toString());
if (res) console.log('completed batch SDK ' + op + ' status: ' + res.transportObj.statusCode + ' ' + res.transportObj.statusMessage);
} catch (error) {
console.log(error);
}
};
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.