UDP Client for Azure IoT Edge
This Azure IoT Edge module is a reference for handling UDP messages on Azure IoT Edge.
This repository has two parts:
- Azure IoT Edge UDP Client module
- UDP Test server (C# .Net Core) application
This reference module shows to ingest regular UDP messages and sends them to the IoT Hub.
There is no actual handling (filtering, aggregation, etc.) of the incoming messages.
The current solution is also not optimized for speed. Due to the nature of UDP (no acknowledge of messages) there is a potential risk in missing messages being sent by the server.
In a professional solution, receiving UDP messsages should be separated by (time consuming) message handling. A queue in between should optimize message handling without losing messages sent.
The code is flexible, please check your own requirements.
This module exposes two outputs:
- 'output1' for UDP messages
- 'outputError' for logging messages
In pseudo, the following JSON message is exposed:
{
DateTime timeStamp
string address
int port
string message
}
In pseudo, the following JSON message is exposed:
{
string logLevel
string code
string message
}
The module supports the following properties:
{
"clientListeningPort" : 11001,
"minimalLogLevel" : 3
}
This is the port the client is listening on.
The desired property 'clientListeningPort' has a default value of 11001.
This is the minimal log level used to send trace=0/debug=1/information=2/warning=3/error=4/critical=6/none=6 messages over the "outputError" output (lower means more messages).
The desired property 'minimalLogLevel' has a default value of Warning (3).
The following container create options must be configured to expose the client listening port:
{
"ExposedPorts": {
"11001/udp":{}
},
"HostConfig": {
"PortBindings":{
"11001/udp":[
{
"HostPort":"11001"
}
]
}
}
}
The client is listening on the public IP of the host, together with the configured port.
https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.udpclient.beginreceive?view=net-5.0