You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(o =>
{
o.ListenAnyIP(1883, l => l.UseMqtt());
o.ListenAnyIP(5000);
});
var optionBuilder = new MqttServerOptionsBuilder()
.WithoutDefaultEndpoint()
.Build();
builder.Services.AddControllers();
builder.Services.AddHostedMqttServer(optionBuilder);
builder.Services.AddMqttConnectionHandler();
builder.Services.AddConnections();
var app = builder.Build();
app.UseAuthorization();
app.MapControllers();
app.Run();
StatusController.cs:
private readonly MqttHostedServer _mqttServer;
public StatusController(MqttHostedServer mqttServer)
{
_mqttServer = mqttServer;
}
[HttpGet]
public async Task<IActionResult> GetConnectedClientsAsync()
{
var clients = await _mqttServer.GetClientsAsync();
return Ok(clients);
}
Line var clients = await _mqttServer.GetClientsAsync(); throws InvalidOperationException: The MQTT server is not started, but client can connect successufuly. Do I have two instances of Mqtt server in my app? How to do it in .NET 6? I saw documentation and samples for .NET 5 but I can't make it work.
The text was updated successfully, but these errors were encountered:
Program.cs:
StatusController.cs:
Line
var clients = await _mqttServer.GetClientsAsync();
throws InvalidOperationException: The MQTT server is not started, but client can connect successufuly. Do I have two instances of Mqtt server in my app? How to do it in .NET 6? I saw documentation and samples for .NET 5 but I can't make it work.The text was updated successfully, but these errors were encountered: