From 978694b3c05dd6dff239e6e760056a918829a7b9 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Sat, 7 Jul 2018 10:52:24 +0200 Subject: [PATCH] set binary mode --- Source/MQTTnet.AspnetCore/MqttConnectionHandler.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/MQTTnet.AspnetCore/MqttConnectionHandler.cs b/Source/MQTTnet.AspnetCore/MqttConnectionHandler.cs index 49a5c09..2390389 100644 --- a/Source/MQTTnet.AspnetCore/MqttConnectionHandler.cs +++ b/Source/MQTTnet.AspnetCore/MqttConnectionHandler.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Connections; +using Microsoft.AspNetCore.Connections.Features; using MQTTnet.Adapter; using MQTTnet.Serializer; using MQTTnet.Server; @@ -13,6 +14,14 @@ namespace MQTTnet.AspNetCore public override async Task OnConnectedAsync(ConnectionContext connection) { + // required for websocket transport to work + var transferFormatFeature = connection.Features.Get(); + if (transferFormatFeature != null) + { + transferFormatFeature.ActiveFormat = TransferFormat.Binary; + } + + var serializer = new MqttPacketSerializer(); using (var adapter = new MqttConnectionContext(serializer, connection)) {