-
I'm intercepting messages on a custom server and want to attach some metadata before passing on to clients. Here is my interceptor: private static async Task OnMessagePublished(InterceptingPublishEventArgs a)
{
Console.WriteLine("message received");
var topic = a.ApplicationMessage.Topic;
var payload = a.ApplicationMessage.ConvertPayloadToString();
Console.WriteLine("payload:" + payload);
var recordNumber = await Store.Append(topic, payload);
Console.WriteLine("recordNumber: " + recordNumber);
a.ApplicationMessage.UserProperties = new()
{
new("RecordNumber", recordNumber.ToString())
};
} And on my custom client I want to retrieve the UserProperties but the collection is null: private static async Task MessageReceived(MqttApplicationMessageReceivedEventArgs arg)
{
var message = arg.ApplicationMessage;
var payload = message.ConvertPayloadToString();
Console.WriteLine("Message received, payload: " + payload);
Console.WriteLine("UserProperties is null: " + (message.UserProperties is null));
Console.WriteLine("Record number:" + message.UserProperties.Where(p => p.Name == "RecordNumber").Select(p => p.Value));
await arg.AcknowledgeAsync(CancellationToken.None);
} What am I missing? This is NET6 and version 4.1.2.350 |
Beta Was this translation helpful? Give feedback.
Answered by
chkr1011
Oct 30, 2022
Replies: 1 comment 1 reply
-
Did you set the protocol version to 5.0.0 in the client options? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rofr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you set the protocol version to 5.0.0 in the client options?