MQTTnet
MQTTnet copied to clipboard
ContentType not set when receiving message (3.0.8)
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:
- Publish a
MqttApplicationMessagethat has itsContentTypeproperty set - Receive a
MqttApplicationMessageandContentTypeisnull
Expected behavior
Expected ContentType to be set to process the message body based on the ContentType.
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.
THen why currently have that property exposed if it is not working? Then I expect it to raise a NotSupportedException when used.
@chkr1011 This is something you need to answer, please.
@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.
@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?
@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...
@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 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 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.
The is now a pull request (#1527) which adds feature validations.