MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

ContentType not set when receiving message (3.0.8)

Open ramonsmits opened this issue 6 years ago • 9 comments

Describe the bug

ContentType not set when receiving a message.

Which project is your bug related to?

  • Client

To Reproduce

Steps to reproduce the behavior:

  1. Publish a MqttApplicationMessage that has its ContentType property set
  2. Receive a MqttApplicationMessage and ContentType is null

Expected behavior

Expected ContentType to be set to process the message body based on the ContentType.

ramonsmits avatar Aug 29 '19 08:08 ramonsmits

I assume that content type is a MQTT 5 property?

Well, this is not yet supported. MQTT5 support will be done in Version 3.1.x.

SeppPenner avatar Aug 29 '19 08:08 SeppPenner

THen why currently have that property exposed if it is not working? Then I expect it to raise a NotSupportedException when used.

ramonsmits avatar Aug 29 '19 08:08 ramonsmits

@chkr1011 This is something you need to answer, please.

SeppPenner avatar Aug 29 '19 09:08 SeppPenner

@SeppPenner You are right with 3.1x. But this only applies for the server. The MQTT client should support all MQTTv5 features already. If not it is a bug and must be added/fixed.

The MQTTv5 support for the server (apart from plain message processing with new properties) will come with 3.1.

I will have a look whats going wrong.

chkr1011 avatar Aug 29 '19 17:08 chkr1011

@ramonsmits Which version are you using? I created a UnitTest but it works as expected for me. Do you have some sample code for me?

chkr1011 avatar Aug 29 '19 17:08 chkr1011

@SeppPenner You are right with 3.1x. But this only applies for the server. The MQTT client should support all MQTTv5 features already. If not it is a bug and must be added/fixed.

You're right. My mistake, I didn't read that this was a client issue...

SeppPenner avatar Aug 29 '19 17:08 SeppPenner

@chkr1011 version 3.0.8 as mentioned in the title. I'm using it with RabbitMQ but your comment make me wonder if it then is a limitation by RabbitMQ not yet supporting MQTTv5? If so, shouldn't I be getting an exception for setting properties that are not supported by the MQTT server or is that something that cannot be detected by the client?

ramonsmits avatar Aug 30 '19 12:08 ramonsmits

@ramonsmits Ah 3.0.8. Did not read the issue title 😄

Do you use the protocol version correctly when connecting? If it does not support you should get an exception while disconnecting. When using the property in combination with 3.1.1 then you will not get an exception. Those checks are not implemented yet (but already requested).

chkr1011 avatar Aug 30 '19 18:08 chkr1011

@chkr1011 I'm not using WithProtocolVersion, I wasn't aware there was an API for that. Based on the following docs it seems I was using the default value which is MqttProtocolVersion.V311.

  • https://github.com/chkr1011/MQTTnet/wiki/Server-and-client-method-documentation

I'm using RabbitMQ MQTT plugin and that seems to be MQTT protocol version 3.1.1 which means I can't make use of these properties.

  • https://www.rabbitmq.com/mqtt.html

Those checks are not implemented yet (but already requested).

What is the issue? I think this issue can be closed when linked to that issue.

ramonsmits avatar Sep 09 '19 09:09 ramonsmits

The is now a pull request (#1527) which adds feature validations.

chkr1011 avatar Nov 12 '22 11:11 chkr1011