Azure / iot-edge-modbus

Modbus protocol module for use with the Azure IoT Edge
Other
90 stars 71 forks source link

Add content properties to the message sent to the output #91

Closed sandervandevelde closed 2 years ago

sandervandevelde commented 4 years ago

This is an issue related to this MS Learn question.

Please add these two lines to every outgoing message:

message.ContentType = "application/json";
message.ContentEncoding = "utf-8";

Aslo, here and here, the message is encoded using ASCII encoding.

ASCII encoding is not supported by the IoT Hub routing.

Is this the right encoding to be used when we add UTF8 encoding later on? What is the risk moving over to UTF8 on these two lines?

qamaruddin commented 4 years ago

We are also facing the similar issues. The messages stored to blob storage through message routing mechanism are all encoded because of content type.

sandervandevelde commented 4 years ago

I forked this repo to https://github.com/sandervandevelde/iot-edge-modbus and fixed a few things.

Try my module and enjoy the .net core 3.1 version of iot-edge-modbus.

Some considerations and limitations:

Note: This is tested using the Linux version of the containers only. Please perform your own extensive tests.

A pull request is added.

yphuangms commented 4 years ago

Thanks for the information sharing.

Just wanna clarify that this "ASCII encoding is not supported by the IoT Hub routing." statement is true ONLY when utilizing Azure Storage as a routing point. Please read the document here: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c#azure-storage-as-a-routing-endpoint

For those who don't setup Azure storage in routing endpoint, the d2c message in ASCII won't cause issue.

We'll include this fix. And thanks for the catch!

yphuangms commented 2 years ago

Please fork or clone the code for further modification/customization to build modbus module that fullfill your need. This repository is no longer being actively maintained and will be archived. Open issues will be closed.