fix(S2-b): use authenticated WSS on standard TLS port
This commit is contained in:
@@ -11,7 +11,10 @@ namespace FieldLogger.Sync;
|
||||
public sealed record MqttBrokerConfig
|
||||
{
|
||||
public required string Host { get; init; }
|
||||
public int Port { get; init; } = 8884;
|
||||
public int Port { get; init; } = 443;
|
||||
/// <summary>When set, use MQTT over secure WebSockets (normally
|
||||
/// wss://dev.hub.umagul.net/mqtt) instead of raw MQTTS.</summary>
|
||||
public string? WebSocketUri { get; init; }
|
||||
public bool UseTls { get; init; } = true;
|
||||
public required string ClientId { get; init; }
|
||||
/// <summary>Interim credential (username = orgId, password = scoped per-org secret).
|
||||
@@ -52,8 +55,13 @@ public sealed class MqttnetTransport : IMqttTransport, IAsyncDisposable
|
||||
|
||||
_ackTopic = ackTopic;
|
||||
|
||||
var options = new MqttClientOptionsBuilder()
|
||||
.WithTcpServer(_config.Host, _config.Port)
|
||||
var builder = new MqttClientOptionsBuilder();
|
||||
if (string.IsNullOrWhiteSpace(_config.WebSocketUri))
|
||||
builder.WithTcpServer(_config.Host, _config.Port);
|
||||
else
|
||||
builder.WithWebSocketServer(options => options.WithUri(_config.WebSocketUri));
|
||||
|
||||
var options = builder
|
||||
.WithClientId(_config.ClientId)
|
||||
.WithProtocolVersion(MQTTnet.Formatter.MqttProtocolVersion.V500)
|
||||
.WithCleanSession(false) // persistent session (durable)
|
||||
|
||||
Reference in New Issue
Block a user