Replies: 2 comments 1 reply
-
Hi @Erksen. The problem is that the wiki is not always up-to-date (It's quite difficult to keep up with all changes). That's why @chkr1011 decided to only use the wiki for older versions (Below 4.x), can also be found on the top of the wiki page for e.g. the server: https://github.com/dotnet/MQTTnet/wiki/Server --> So, the best is to have a look at the samples directory in the project right now. If you want to, you can check out my project under https://github.com/SeppPenner/SimpleMqttServer/blob/master/src/SimpleMqttServer/MqttService.cs where I have added user validation by username and password. As short example on how it can be done with the asnyc events in V4 of the library: private void SetupServer()
{
var optionsBuilder = new MqttServerOptionsBuilder()
.WithDefaultEndpoint()
.WithDefaultEndpointPort(1883)
.WithEncryptedEndpointPort(8883);
var mqttServer = new MqttFactory().CreateMqttServer(optionsBuilder.Build());
mqttServer.ValidatingConnectionAsync += this.ValidateConnectionAsync;
}
private Task ValidateConnectionAsync(ValidatingConnectionEventArgs args)
{
// ... Do something with the args, e.g. user name and password.
} |
Beta Was this translation helpful? Give feedback.
-
so how do you get the password for comparison from the ValidatingConnectionEventArgs args? |
Beta Was this translation helpful? Give feedback.
-
Hello MQTTnet team,
I am working on a own project with a mqtt server based on your libary.
My goal was to create a server with an user/password validation. Therefor I read the your wiki page on github (image cutout below). It said that I should use for the setup the
withConnectionValidator
function from theMqttServerOptionsBuilder
class. The problem is that this function doesn't exists anymore in the class.Am I doing it wrong?
I hope you can help. Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions