MQTTnet.AspNetCore.Routing icon indicating copy to clipboard operation
MQTTnet.AspNetCore.Routing copied to clipboard

When the server is Sending a Message, the message get descarded from the MqttRouter

Open miaooss opened this issue 10 months ago • 0 comments

Describe the bug

Inside one of the controller Route I'm using this code to send an message to all subscriber // Now inject the new message at the broker. await Server.InjectApplicationMessage(new InjectedMqttApplicationMessage(msg) { SenderClientId = MqttServerConstants.ClientId });

But What I found is an error on the Logs saying that the Message will be drop

https://github.com/IoTSharp/MQTTnet.AspNetCore.Routing/blob/4649da9e28e87b87501962525c96107a6741f491/Source/Routing/MqttRouter.cs#L51

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of MQTTnet 4.X.X

  2. Create a controller then send a message using Server.InjectApplicationMessage

  3. Make sure you are using: app.UseMqttServer(server => { server.WithAttributeRouting(app.ApplicationServices, allowUnmatchedRoutes: false); });

  4. See error.

Expected behavior

A clear and concise description of what you expected to happen.

Need the ability to ignore the Server message from the router by maybe looking at the sender id

Screenshots

None

Additional context / logging

Using this example https://github.com/dotnet/MQTTnet/blob/7f5c437c46dd52ecb1d53dfc8ea9fb8ff46caf5d/Samples/Server/Server_Simple_Samples.cs#L53C12-L53C55

dbug: MQTTnet.AspNetCore.Routing.MqttRouter[0]
      Rejecting message publish because 'route/path' did not match any known routes.

miaooss avatar Apr 12 '24 22:04 miaooss