asp.net core 2.1 - ConfigureServices - How to build-up MQTT Server Options
See original GitHub issueConsidering this code:
var mqttServerOptions = new MqttServerOptionsBuilder()
.WithDefaultEndpoint()
.WithDefaultEndpointPort(9876)
.WithConnectionValidator((ctx) =>
{
var mediator = serviceProvider.GetService<IMediator>();
if (await mediator.Send(new AuthenticateTerminalForMqttCommand(ctx.Username, ctx.Password)))
{
logger.LogInformation("Client {0} has connected.", ctx.ClientId);
ctx.ReturnCode = MqttConnectReturnCode.ConnectionAccepted;
return;
}
logger.LogInformation("Client {0} has failed to authenticate.", ctx.ClientId);
ctx.ReturnCode = MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword;
})
.Build();
We cannot pull anything into ConfigureServices() but the IServiceCollection object. So, with asp.net core 2.1, how do we provide a connection validator, among other items? When I look at the main Configure() method, although we can do app.UseMqttServer((mqttServer) => { ... custom code here ... });, it does not seem to let us assign a custom connection validator, as the property is marked as ReadOnly at this point.
Any suggestions/ideas for how to overcome this want/need would be great.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
asp.net core 2.1 - ConfigureServices - How to build-up ...
Considering this code: var mqttServerOptions = new MqttServerOptionsBuilder() .WithDefaultEndpoint() .WithDefaultEndpointPort(9876) .
Read more >Server · dotnet/MQTTnet Wiki
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation...
Read more >how to use GetConnectedClientsAsync from MQTTnet. ...
I can host mqtt broker with MQTTnet nuget in asp.net core 2.2 by following code. I just want to show list of connected...
Read more >NET Generic Host in ASP.NET Core
The ConfigureWebHostDefaults method: Loads host configuration from environment variables prefixed with ASPNETCORE_ . Sets Kestrel server as the ...
Read more >Creating a Daemon with .NET Core (Part 2)
Now, you can build and run the app. To do so, first run dotnet build in the root directory of the app. Next,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

the problem is that the new pipeline does not yet support encrypted communication. (there is no tls connection middleware yet and using sslstream negates all the performance benefits)
so you should remove
and instead add the old tcp server adapter with
That’s pretty much what I wound up with. I now need to go through the bowels of the wire-up and see if its going to be possible or not to build an orleans backplane for this, so that we can host this within a web farm environment. I know others have advised against this, but I’m trying to keep our stack as compact as possible until we hit a critical mass.