Skip to content

SDK Send Events not working or erroring #1227

@Skeletor11

Description

@Skeletor11

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);
}
};
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions