dotnet / dotnet/MQTTnet

MqttClientOptionsBuilder.WithTcpServer System.ArgumentException: No endpoint is set

Open
#2,034 0 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
5.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

The `MqttClientOptionsBuilder` using `WithTcpServer` fails with the message "No endpoint is set" while RemoteEndpoint is assigned.

```txt
System.ArgumentException: No endpoint is set.
at MQTTnet.Client.MqttClientOptionsBuilder.Build()
```

```c#
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:

```c#
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:
1. Using this version of MQTTnet 4.3.6.1152
2. Run this code, see above
3. With these arguments, see above
4. See error, see above

### Expected behavior

Builder to succeed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.