Hello. I am using the Mqtt server with the AspNetCore integration and trying to upgrade to .Net 5 (RC2).
Sadly I get a compile error after upgrading to the latest Mqtt + .Net5 RC2 packages.
The error is:
CS7069 Reference to type 'ConnectionsRouteBuilder' claims it is defined in 'Microsoft.AspNetCore.Http.Connections', but it could not be found.
I found out that the type ConnectionsRouterBuilder is removed with .Net 5 hence the error.
The actual question: Is .Net 5 compatibility in work or is it planned? And if so will it be shipped before the .Net 5 release next month?
Thanks in advance
Edit:
The method in question is
app.UseEndpoints(endpoints =>
{
endpoints.MapMqtt("/mqtt");
});
Is .Net 5 compatibility in work or is it planned?
nothing is planned but I will update MqttNet.AspnetCore as soon as AspnetCore is Released and most likely ifdef my way to compatibility.
And if so will it be shipped before the .Net 5 release next month?
no it will certainly not be shipped before .Net 5 release. maybe in december when im on vakation and have some spare time. If you need to early adopt .Net 5 feel free to create a pr.
this seems to be the the issue:
https://docs.microsoft.com/en-us/dotnet/core/compatibility/3.1-5.0#signalr-usesignalr-and-useconnections-methods-removed
Hi @StefanOssendorf @JanEggers
I made it work on NET 5.0 by just changing these lines in Startup.cs:
Old startup.cs:
app.UseEndpoints(endpoints =>
{
endpoints.MapMqtt("/mqtt");
});
.NET5 Startup.cs:
app.UseEndpoints(endpoints =>
{
endpoints.MapConnectionHandler<MqttConnectionHandler>("/mqtt");
});
I made a quick test and it is working without any issue.
Cheers
MapMqtt should call exactly that I guess ms just changed some types so the extension is not recogniced
Hi, maybe this is helpful for someone. Using the solution from @Jossec101 we still had a problem with the "Sec-WebSocket-Protocol".
WebSocket connection to '...' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received
To fix that we had to specify a SubProtocolSelector, like this:
builder.MapConnectionHandler<MqttConnectionHandler>("/api-gateway",
httpConnectionDispatcherOptions => httpConnectionDispatcherOptions.WebSockets.SubProtocolSelector = protocolList => protocolList.FirstOrDefault() ?? string.Empty);
@SeppPenner Should we add the above hint to the wiki and close this issue?
Good idea, if you ask me :)
Is it correct like this: https://github.com/chkr1011/MQTTnet/wiki/Server#net-50? If yes, we can close the issue :)
If somethings wrong just tell me and I will update the information :)
Most helpful comment
Hi, maybe this is helpful for someone. Using the solution from @Jossec101 we still had a problem with the "Sec-WebSocket-Protocol".
WebSocket connection to '...' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was receivedTo fix that we had to specify a SubProtocolSelector, like this:
builder.MapConnectionHandler<MqttConnectionHandler>("/api-gateway", httpConnectionDispatcherOptions => httpConnectionDispatcherOptions.WebSockets.SubProtocolSelector = protocolList => protocolList.FirstOrDefault() ?? string.Empty);