Describe the bug
There is no valid replacement for MqttClientOptionBuilder.WithConnectionUri that will accept the same range of URIs as the original method.
Which component is your bug related to?
To Reproduce
- Using this version of MQTTnet '4.3.3.952'.
Expected behaviour
Something that accepts an arbitrary supported URI and produces a valid MqttClientOptions for connecting to the MQTT server described by the URI.
Code example
WithConnectionUri is marked as Obsolete:
var mqttClientOptions = mqttFactory.CreateClientOptionsBuilder()
.WithConnectionUri(configuration.GetUri())
.Build()
It suggests using WithWebSocketServer, which assumes you know that the given URI uses WebSockets and will presumably fail if it is not a WebSockets URI:
var mqttClientOptions = mqttFactory.CreateClientOptionsBuilder()
// Note: you must explicitly declare the type. Otherwise, it uses _another_ deprecated method of the same name.
.WithWebSocketServer((MqttClientWebSocketOptionsBuilder opt) => {
opt.WithUri(image.GetUri());
})
.Build()
Alternatively, it suggests using WtihTcpServer, which can't parse any URIs:
var mqttClientOptions = mqttFactory.CreateClientOptionsBuilder()
.WithTcpServer((MqttClientWebSocketOptionsBuilder opt) => {
opt.WithUri(image.GetUri()); // <-- compile error, no such method.
})
.Build()
Describe the bug
There is no valid replacement for MqttClientOptionBuilder.WithConnectionUri that will accept the same range of URIs as the original method.
Which component is your bug related to?
To Reproduce
Expected behaviour
Something that accepts an arbitrary supported URI and produces a valid MqttClientOptions for connecting to the MQTT server described by the URI.
Code example
WithConnectionUri is marked as Obsolete:
It suggests using WithWebSocketServer, which assumes you know that the given URI uses WebSockets and will presumably fail if it is not a WebSockets URI:
Alternatively, it suggests using WtihTcpServer, which can't parse any URIs: