denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.26k stars 5.41k forks source link

SDK Send Events not working or erroring #27201

Open Skeletor11 opened 1 day ago

Skeletor11 commented 1 day ago

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);
      }
    };
  }
marvinhagemeister commented 21 hours ago

Does the error occur in the latest Deno version 2.1.2 as well?

Skeletor11 commented 8 hours ago

Yes