MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

Question - When to call UseMqtt() for Kestrel

Open wobbet opened this issue 1 year ago • 1 comments

Looking at the ASPNET Core example for Kestrel it has the following code during configuration...

opts.ListenAnyIP(1883, l => l.UseMqtt());
opts.ListenAnyIP(5000); // Default HTTP pipeline

When do I choose to invoke UseMqtt() and when do I not?

I think it is whether or not I'm switching to a TCP connection versus forwarding an HTTP connection, but I want to make sure before I do something stupid and blow up my app.

wobbet avatar Feb 19 '25 22:02 wobbet

kestrel by default is http when u UseMqtt it switches the protocol for that port to use tcp based mqtt.

if you are using mqtt in the web (websockets) you dont need it. if you want to communicate with machines you do need it.

JanEggers avatar Feb 27 '25 07:02 JanEggers