Closed ksami closed 6 years ago
why would you add a client on the server?
you can use mqtt.js directly in the browser to connect to a mqtt broker.
The consumer for the API is not a browser. In my case, the API acts as a webhook for a server in a 3rd party system to call, which will then trigger updates to be sent to MQTT subscribers. Do you know what is the recommendation for using the MQTT client in this way?
if you dont need to hanle incoming messages but just send messages if an api is called i would create a new client for each method call.
Thanks! There might be a requirement in the future to receive messages too to process updates from the subscribers. In that case, would it still be better to create a new client for each request?
in case you need to receive messages you can create an IHostedService that has its own client and processes the messages.
Huh why didn't I think of that... Thanks for the help!
Hi, what is the recommended way of using the MQTT client in a .NET Core 2 WebAPI? Eg. creating a new instance of client for every request or reusing the same instance? Would using ManagedClient help in this case?