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

No support for dt-subject on HTTP Transport #1141

Closed
ymoreiratiti opened this issue Jul 25, 2022 · 5 comments
Closed

No support for dt-subject on HTTP Transport #1141

ymoreiratiti opened this issue Jul 25, 2022 · 5 comments
Assignees
Labels

Comments

@ymoreiratiti
Copy link

ymoreiratiti commented Jul 25, 2022

Context

  • OS and version used: Windows 11 with WSL2
  • Node.js version: 16.15.1
  • npm version: 8.12.2
  • list of installed packages: {"azure-iot-device-http": "^1.14.0",}

Description of the issue

When using the HTTP transport layer, the message property "dt-subject" is transformed to "iothub-app-dt-subject". This makes the Azure Hub API ignore the subject and show the message as unmodeled data.

Code sample exhibiting the issue

const message = new Message(
          JSON.stringify({
            datetimeSignal,
            line,
            version: iotDataCollectorProperties.lastCollectFlightReports,
          }),
        );

        message.properties.add('dt-subject', 'logHistory');
        message.contentType = 'application/json';
        message.contentEncoding = 'utf-8';

        await azureIoTClientMqtt.sendEvent(message);

image


Analysing the code I found the code block where all message properties is added to the header with the prefix iothub-app

httpHeaders[MESSAGE_PROP_HEADER_PREFIX + propItem.key] = propItem.value;


The same appear to be happening with sendEventBatch. Check this file:

property += '\"' + MESSAGE_PROP_HEADER_PREFIX + propItem.key + '\":\"' + propItem.value + '\"';


I believe he should detect when the message property is dt-subject and ignore prefix, so the header should be only "dt-subject".

@github-actions github-actions bot added the IoTSDK tracks all IoT SDK issues across the board label Jul 25, 2022
@anthonyvercolano anthonyvercolano self-assigned this Aug 8, 2022
@anthonyvercolano
Copy link
Contributor

anthonyvercolano commented Aug 8, 2022

Well, um, maybe. Since PnP is still in preview, it's questionable whether we should be special casing dt-subject.

If you look in some other later preview material, usually in helper samples, you would see this as $.sub

You would find that in 'c'. Note that 'c' ONLY supports MQTT. C sharp, much to my surprise, does seem to support what you want for HTTP.

So, why not utilize MQTT? You can use MQTT over websockets if you face firewall issues.

@ymoreiratiti
Copy link
Author

In my scenario, I have a cronjob who downloads the log and sends it line by line. Currently, I'm using MQTT and doing an iteration for each file line, but I believe using the batch will be more network optimized.

@anthonyvercolano
Copy link
Contributor

@ymoreiratiti I'm not understanding here.

What are your referring to when you say "batch"? How does "batch" interact with using HTTP?

@ymoreiratiti
Copy link
Author

@anthonyvercolano for batch i'm refering to sendEventBatch.

You can send multiple messages with one request.

@anthonyvercolano
Copy link
Contributor

Released

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

2 participants