Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK Send Events not working or erroring #1227

Open
Skeletor11 opened this issue Dec 3, 2024 · 0 comments
Open

SDK Send Events not working or erroring #1227

Skeletor11 opened this issue Dec 3, 2024 · 0 comments
Labels

Comments

@Skeletor11
Copy link

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:[email protected]';
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);
}
};
}

@Skeletor11 Skeletor11 added the bug label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant