MQTTnet
MQTTnet copied to clipboard
MqttClientOptionsBuilder.WithTcpServer System.ArgumentException: No endpoint is set
Describe the bug
The MqttClientOptionsBuilder using WithTcpServer fails with the message "No endpoint is set" while RemoteEndpoint is assigned.
System.ArgumentException: No endpoint is set.
at MQTTnet.Client.MqttClientOptionsBuilder.Build()
var options = new MqttClientOptionsBuilder()
.WithTcpServer(s =>
{
s.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork;
s.RemoteEndpoint = new DnsEndPoint(Server.Host, Server.Port);
})
.Build();
Doing the following works:
var options = new MqttClientOptionsBuilder()
.WithEndPoint(new DnsEndPoint(Server.Host, Server.Port,System.Net.Sockets.AddressFamily.InterNetwork))
.Build();
I'm not sure on the differences between these API's but I think WithTcpServer should be able to be used without WithEndPoint.
Maybe WithTcpServer is obsolete?
Which component is your bug related to?
- Client
To Reproduce
Steps to reproduce the behavior:
- Using this version of MQTTnet 4.3.6.1152
- Run this code, see above
- With these arguments, see above
- See error, see above
Expected behavior
Builder to succeed.