mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 11:45:43 +08:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fdee9e0db | ||
|
|
cae7206733 | ||
|
|
e2e7aacc09 |
@@ -1,11 +1,2 @@
|
|||||||
* [Client] Fixed _PlatformNotSupportedException_ when using Blazor (#1755, thanks to @Nickztar).
|
* [Client] Fixed wrong TLS options handling (#1830).
|
||||||
* [Client] Added hot reload of client certificates (#1781).
|
* [Client] Fixed NullReferenceExeption when performing a Ping when the client is not connected (#1831).
|
||||||
* [Client] Added several new option builders and aligned usage (#1781, BREAKING CHANGE!).
|
|
||||||
* [Client] Added support for _RemoteCertificateValidationCallback_ for .NET 4.5.2, 4.6.1 and 4.8 (#1806, thanks to @troky).
|
|
||||||
* [Client] Fixed wrong logging of obsolete feature when connection was not successful (#1801, thanks to @ramonsmits).
|
|
||||||
* [Client] Fixed _NullReferenceException_ when performing several actions when not connected (#1800, thanks to @ramonsmits).
|
|
||||||
* [RpcClient] Added support for passing custom parameters to topic generation context (#1798, thanks to @Temppus).
|
|
||||||
* [Server] Fixed _NullReferenceException_ in retained messages management (#1762, thanks to @logicaloud).
|
|
||||||
* [Server] Exposed new option which allows disabling packet fragmentation (#1753).
|
|
||||||
* [Server] Expired sessions will no longer be used when a client connects (#1756).
|
|
||||||
* [Server] Fixed an issue in connection handling for ASP.NET connections (#1819, thanks to @CZEMacLeod).
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: CI
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VERSION: "4.3.0.${{github.run_number}}"
|
VERSION: "4.3.1.${{github.run_number}}"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -430,6 +430,9 @@ public static class Client_Connection_Samples
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Console.WriteLine("Press <Enter> to exit");
|
||||||
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,13 +47,13 @@ namespace MQTTnet.Extensions.WebSocket4Net
|
|||||||
var uri = _webSocketOptions.Uri;
|
var uri = _webSocketOptions.Uri;
|
||||||
if (!uri.StartsWith("ws://", StringComparison.OrdinalIgnoreCase) && !uri.StartsWith("wss://", StringComparison.OrdinalIgnoreCase))
|
if (!uri.StartsWith("ws://", StringComparison.OrdinalIgnoreCase) && !uri.StartsWith("wss://", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (_webSocketOptions.TlsOptions?.UseTls == false)
|
if (_webSocketOptions.TlsOptions?.UseTls == true)
|
||||||
{
|
{
|
||||||
uri = "ws://" + uri;
|
uri = "wss://" + uri;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uri = "wss://" + uri;
|
uri = "ws://" + uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ namespace MQTTnet.TestApp
|
|||||||
UseTls = true,
|
UseTls = true,
|
||||||
SslProtocol = SslProtocols.Tls13,
|
SslProtocol = SslProtocols.Tls13,
|
||||||
// Don't use this in production code. This handler simply allows any invalid certificate to work.
|
// Don't use this in production code. This handler simply allows any invalid certificate to work.
|
||||||
CertificateValidationHandler = w => true
|
AllowUntrustedCertificates = true,
|
||||||
|
IgnoreCertificateChainErrors = true,
|
||||||
|
CertificateValidationHandler = _ => true
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// Also defining TLS12 for servers that don't seem no to support TLS13.
|
// Also defining TLS12 for servers that don't seem no to support TLS13.
|
||||||
@@ -34,7 +36,9 @@ namespace MQTTnet.TestApp
|
|||||||
UseTls = true,
|
UseTls = true,
|
||||||
SslProtocol = SslProtocols.Tls12,
|
SslProtocol = SslProtocols.Tls12,
|
||||||
// Don't use this in production code. This handler simply allows any invalid certificate to work.
|
// Don't use this in production code. This handler simply allows any invalid certificate to work.
|
||||||
CertificateValidationHandler = w => true
|
AllowUntrustedCertificates = true,
|
||||||
|
IgnoreCertificateChainErrors = true,
|
||||||
|
CertificateValidationHandler = _ => true
|
||||||
};
|
};
|
||||||
|
|
||||||
// mqtt.eclipseprojects.io
|
// mqtt.eclipseprojects.io
|
||||||
@@ -97,10 +101,10 @@ namespace MQTTnet.TestApp
|
|||||||
"test.mosquitto.org WS TLS12",
|
"test.mosquitto.org WS TLS12",
|
||||||
new MqttClientOptionsBuilder().WithWebSocketServer(o => o.WithUri("test.mosquitto.org:8081/mqtt")).WithProtocolVersion(MqttProtocolVersion.V311).WithTlsOptions(unsafeTls12).Build());
|
new MqttClientOptionsBuilder().WithWebSocketServer(o => o.WithUri("test.mosquitto.org:8081/mqtt")).WithProtocolVersion(MqttProtocolVersion.V311).WithTlsOptions(unsafeTls12).Build());
|
||||||
|
|
||||||
// await ExecuteTestAsync(
|
await ExecuteTestAsync(
|
||||||
// "test.mosquitto.org WS TLS12 (WebSocket4Net)",
|
"test.mosquitto.org WS TLS12 (WebSocket4Net)",
|
||||||
// new MqttClientOptionsBuilder().WithWebSocketServer("test.mosquitto.org:8081/mqtt").WithProtocolVersion(MqttProtocolVersion.V311).WithTls(unsafeTls12).Build(),
|
new MqttClientOptionsBuilder().WithWebSocketServer(o => o.WithUri("test.mosquitto.org:8081/mqtt")).WithProtocolVersion(MqttProtocolVersion.V311).WithTlsOptions(unsafeTls12).Build(),
|
||||||
// true);
|
true);
|
||||||
|
|
||||||
// broker.emqx.io
|
// broker.emqx.io
|
||||||
await ExecuteTestAsync(
|
await ExecuteTestAsync(
|
||||||
@@ -150,7 +154,6 @@ namespace MQTTnet.TestApp
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
// mqtt.swifitch.cz: Does not seem to operate any more
|
// mqtt.swifitch.cz: Does not seem to operate any more
|
||||||
|
|
||||||
// cloudmqtt.com: Cannot test because it does not offer a free plan any more.
|
// cloudmqtt.com: Cannot test because it does not offer a free plan any more.
|
||||||
|
|
||||||
Write("Finished.", ConsoleColor.White);
|
Write("Finished.", ConsoleColor.White);
|
||||||
@@ -197,9 +200,10 @@ namespace MQTTnet.TestApp
|
|||||||
|
|
||||||
Write("[OK]\n", ConsoleColor.Green);
|
Write("[OK]\n", ConsoleColor.Green);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Write("[FAILED] " + e.Message + "\n", ConsoleColor.Red);
|
Write("[FAILED]" + Environment.NewLine, ConsoleColor.Red);
|
||||||
|
Write(exception + Environment.NewLine, ConsoleColor.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,11 @@ namespace MQTTnet.Client
|
|||||||
|
|
||||||
public async Task PingAsync(CancellationToken cancellationToken = default)
|
public async Task PingAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
ThrowIfDisposed();
|
||||||
|
ThrowIfNotConnected();
|
||||||
|
|
||||||
if (cancellationToken.CanBeCanceled)
|
if (cancellationToken.CanBeCanceled)
|
||||||
{
|
{
|
||||||
await Request<MqttPingRespPacket>(MqttPingReqPacket.Instance, cancellationToken).ConfigureAwait(false);
|
await Request<MqttPingRespPacket>(MqttPingReqPacket.Instance, cancellationToken).ConfigureAwait(false);
|
||||||
@@ -441,7 +446,7 @@ namespace MQTTnet.Client
|
|||||||
|
|
||||||
if (receivedPacket is MqttConnAckPacket connAckPacket)
|
if (receivedPacket is MqttConnAckPacket connAckPacket)
|
||||||
{
|
{
|
||||||
result = MqttClientResultFactory.ConnectResult.Create(connAckPacket, _adapter.PacketFormatterAdapter.ProtocolVersion);
|
result = MqttClientResultFactory.ConnectResult.Create(connAckPacket, channelAdapter.PacketFormatterAdapter.ProtocolVersion);
|
||||||
}
|
}
|
||||||
else if (receivedPacket is MqttAuthPacket)
|
else if (receivedPacket is MqttAuthPacket)
|
||||||
{
|
{
|
||||||
@@ -513,7 +518,7 @@ namespace MQTTnet.Client
|
|||||||
using (var effectiveCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(backgroundCancellationToken, cancellationToken))
|
using (var effectiveCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(backgroundCancellationToken, cancellationToken))
|
||||||
{
|
{
|
||||||
_logger.Verbose("Trying to connect with server '{0}'", Options.ChannelOptions);
|
_logger.Verbose("Trying to connect with server '{0}'", Options.ChannelOptions);
|
||||||
await _adapter.ConnectAsync(effectiveCancellationToken.Token).ConfigureAwait(false);
|
await channelAdapter.ConnectAsync(effectiveCancellationToken.Token).ConfigureAwait(false);
|
||||||
_logger.Verbose("Connection with server established");
|
_logger.Verbose("Connection with server established");
|
||||||
|
|
||||||
_publishPacketReceiverQueue?.Dispose();
|
_publishPacketReceiverQueue?.Dispose();
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ namespace MQTTnet.Client
|
|||||||
throw new InvalidOperationException("A channel must be set.");
|
throw new InvalidOperationException("A channel must be set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var tlsOptions = _tlsOptions;
|
// The user can specify the TCP options with already configured TLS options
|
||||||
|
// or start with TLS settings not knowing which transport will be used (depending
|
||||||
|
// on the order of called methods from the builder).
|
||||||
|
// The builder prefers the explicitly set TLS options!
|
||||||
|
var tlsOptions = _tlsOptions ?? _tcpOptions?.TlsOptions;
|
||||||
|
|
||||||
if (_tlsParameters != null)
|
if (_tlsParameters != null)
|
||||||
{
|
{
|
||||||
if (_tlsParameters?.UseTls == true)
|
if (_tlsParameters?.UseTls == true)
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ namespace MQTTnet.Implementations
|
|||||||
var uri = _options.Uri;
|
var uri = _options.Uri;
|
||||||
if (!uri.StartsWith("ws://", StringComparison.OrdinalIgnoreCase) && !uri.StartsWith("wss://", StringComparison.OrdinalIgnoreCase))
|
if (!uri.StartsWith("ws://", StringComparison.OrdinalIgnoreCase) && !uri.StartsWith("wss://", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (_options.TlsOptions?.UseTls == false)
|
if (_options.TlsOptions?.UseTls == true)
|
||||||
{
|
{
|
||||||
uri = "ws://" + uri;
|
uri = "wss://" + uri;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uri = "wss://" + uri;
|
uri = "ws://" + uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user