Reputation: 3053
I'm trying to understand what affects Azure IoT Hub message counter.
I'm sending a simplae JSON formatted message from a Raspberry Pi 3 device running Windows IoT Core. The message size is probably around 1kb.
I have a simple Function that watches for new messages and stores them in a Table storage as they arrive.
Each message apprears to increment the Azure IoT Hub message counter by about 10 (rather than expected 1)
I have not found any reference to this - but does message size somewhow affects how messages are counted?
EDIT
The follwoing code sample once has just bumped up the message counter in Azure by 4
using Microsoft.Azure.Devices.Client;
using System;
using System.Text;
namespace ConsoleApp1
{
class Program
{
private static DeviceClient deviceClient;
private static string iotHubUri = "iothubaccount.azure-devices.net";
private static string deviceKey = "devicekey";
private static string reading = @"{
cycle:0,
tempCentre:16.25,
trCentre:627,
tempCorner:16.00,
trCorner:619,
data: [
[{val: 643, convVal: 14.31, valA: 644}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 628, convVal: 18.61, valA: 628}, {val: 620, convVal: 20.91, valA: 621}, {val: 622, convVal: 20.34, valA: 620}, {val: 621, convVal: 20.62, valA: 620}],
[{val: 645, convVal: 13.74, valA: 645}, {val: 1020, convVal: -93.84, valA: 1021}, {val: 630, convVal: 18.04, valA: 629}, {val: 620, convVal: 20.91, valA: 621}, {val: 620, convVal: 20.91, valA: 621}, {val: 621, convVal: 20.62, valA: 621}],
[{val: 644, convVal: 14.02, valA: 644}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 627, convVal: 18.90, valA: 627}, {val: 620, convVal: 20.91, valA: 620}, {val: 621, convVal: 20.62, valA: 621}, {val: 620, convVal: 20.91, valA: 620}],
[{val: 667, convVal: 7.43, valA: 667}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 733, convVal: -11.51, valA: 732}, {val: 644, convVal: 14.02, valA: 643}, {val: 645, convVal: 13.74, valA: 645}, {val: 644, convVal: 14.02, valA: 642}],
[{val: 644, convVal: 14.02, valA: 643}, {val: 1021, convVal: -94.13, valA: 1022}, {val: 628, convVal: 18.61, valA: 628}, {val: 619, convVal: 21.20, valA: 618}, {val: 619, convVal: 21.20, valA: 619}, {val: 618, convVal: 21.48, valA: 618}],
[{val: 665, convVal: 8.00, valA: 666}, {val: 1022, convVal: -94.42, valA: 1022}, {val: 648, convVal: 12.88, valA: 649}, {val: 644, convVal: 14.02, valA: 643}, {val: 644, convVal: 14.02, valA: 642}, {val: 643, convVal: 14.31, valA: 643}],
[{val: 1022, convVal: -94.42, valA: 1022}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 1023, convVal: -94.70, valA: 1023}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 1021, convVal: -94.13, valA: 1022}, {val: 1022, convVal: -94.42, valA: 1022}],
[{val: 651, convVal: 12.02, valA: 651}, {val: 1022, convVal: -94.42, valA: 1021}, {val: 654, convVal: 11.16, valA: 654}, {val: 627, convVal: 18.90, valA: 627}, {val: 628, convVal: 18.61, valA: 629}, {val: 629, convVal: 18.33, valA: 627}]
]}
";
static void Main(string[] args)
{
Console.WriteLine("Sending message.");
deviceClient = DeviceClient.Create(iotHubUri, new DeviceAuthenticationWithRegistrySymmetricKey("RegistredDeviceName", deviceKey), TransportType.Mqtt);
var message = new Message(Encoding.ASCII.GetBytes(reading));
deviceClient.SendEventAsync(message).Wait();
Console.WriteLine("Message sent.");
Console.ReadLine();
}
}
}
Upvotes: 0
Views: 1199
Reputation: 9700
The follwoing code sample once has just bumped up the message counter in Azure by 4
It is expected if you use iot hub free edition.
Based on your code sample, your message payload length is 2027(bytes). That will be divided to about 4 iot hub messages(For free edition MESSAGE METER SIZE is 0.5 KB).
You can get the message length using message.BodyStream.Length
.
Upvotes: 1