PLCnext / CSharpExamples

Collection of various C# sample code for PLCnext Technology controllers.
MIT License
13 stars 11 forks source link

Recommended way to communicate with Azure? Http? MQTT? #12

Closed AshWhitear closed 3 years ago

AshWhitear commented 3 years ago

I can see HTTP libs arent currently supported, not sure if there is a way around this? Looking to speak out to Azure with using C# on the device. Thanks, Ash.

martinboers commented 3 years ago

Hi Ash, you're right, the HTTP libraries are currently not supported by the embedded CLR, i.e. in IEC 61131 code or C# code that's running on the eCLR.

There are a few examples of connecting to Azure in the Makers Blog - I think this one is the most recent: https://www.plcnext-community.net/en/hn-makers-blog/589-azure-iot-edge-and-plcnext.html

There is also some support for Azure in the IIoT_Library for PLCnext Engineer, available in the PLCnext Store, which uses MQTT to exchange data with an Azure instance.

You could also run your C# code on .NET Core instead of the eCLR, if you want. This makes more of the standard .NET class libraries available, but makes it more difficult to integrate the C# application with any PLCnext Engineer project running on the same PLC.

mluhmann commented 3 years ago

HTTP libraries will not be implemented any time soon. The purpose of the C# part in the eCLR is to program efficient code with some convenience compared to IEC 61131. Most communication is not meant to run in real time and therefore only basic libraries are implemented.

We recommend (as Martin already proposed) to use other/external runtimes or solutions and use our GDS to exchange data.