shamblett / mqtt5_client

A server and browser based MQTT 5 client for dart
Other
49 stars 25 forks source link

Does this library supports Utf8 Chinese topic name? #65

Closed neardreams closed 10 months ago

neardreams commented 10 months ago

HI~

I tried some Chinese topic names, but raises following exception on the bottom. Everything goes normal when I change the topic name back to just English chars. Does this library supports Utf8 Chinese topic names or did I just misused something? Thanks.

I/flutter (15925): 2023-10-27 09:47:58.753472 -- MqttServerConnection::_onData - Message Received Started <<< I/flutter (15925): 2023-10-27 09:47:58.753624 -- MqttServerConnection::_ondata - adding incoming data, data length is 1487, message stream length is 0, message stream position is 0 I/flutter (15925): 2023-10-27 09:47:58.753701 -- MqttServerConnection::_ondata - added incoming data message stream length is 1487, message stream position is 0 I/flutter (15925): 2023-10-27 09:47:58.753828 -- MqttByteBuffer:isMessageAvailable - assumed valid header, value is 48 I/flutter (15925): 2023-10-27 09:47:58.762594 -- MqttServerConnection::_ondata - exception raised is mqtt-client::InvalidMessageException: The data provided in the message stream was not a valid MQTT Message, exception is Exception: MqttByteBuffer::read: The buffer did not have enough bytes for the read operation length 1454, count 1458, position 0, buffer [123, 13, 10, 32, 32, 34, 115, 99, 101, 110, 97, 114, 105, 111, 115, 34, 58, 32, 91, 123, 34, 105, 110, 100, 101, 120, 34, 58, 49, 44, 34, 110, 97, 109, 101, 34, 58, 34, 230, 184, 172, 232, 169, 166, 230, 131, 133, 229, 162, 131, 233, 150, 139, 49, 34, 44, 34, 115, 99, 101, 110, 97, 114, 105, 111, 84, 121, 112, 101, 34, 58, 50, 44, 34, 105, 100, 34, 58, 50, 57, 125, 44, 123, 34, 105, 110, 100, 101, 120, 34, 58, 50, 44, 34, 110, 97, 109, 101, 34, 58, 34, 230, 184, 172, 232, 169, 166, 230, 131, 133, 229, 162, 131, 233, 151, 156, 34, 44, 34, 115, 99, 101, 110, 97, 114, 105, 111, 84, 121, 112, 101, 34, 58, 50, 44, 34, 105, 100, 34, 58, 51, 48, 125, 44, 123, 34, 105, 110, 100, 10 I/flutter (15925): 2023-10-27 09:47:58.762873 -- MqttServerConnection::_ondata - irrecoverable exception raised - sending disconnect mqtt-client::InvalidMessageException: The data provided in the message stream was not a valid MQTT Message, exception is Exception: MqttByteBuffer::read: The buffer did not have enough bytes for the read operation length 1454, count 1458, position 0, buffer [123, 13, 10, 32, 32, 34, 115, 99, 101, 110, 97, 114, 105, 111, 115, 34, 58, 32, 91, 123, 34, 105, 110, 100, 101, 120, 34, 58, 49, 44, 34, 110, 97, 109, 101, 34, 58, 34, 230, 184, 172, 232, 169, 166, 230, 131, 133, 229, 162, 131, 233, 150, 139, 49, 34, 44, 34, 115, 99, 101, 110, 97, 114, 105, 111, 84, 121, 112, 101, 34, 58, 50, 44, 34, 105, 100, 34, 58, 50, 57, 125, 44, 123, 34, 105, 110, 100, 101, 120, 34, 58, 50, 44, 34, 110, 97, 109, 101, 34, 58, 34, 230, 184, 172, 232, 169, 166, 230, 131, 133, 229, 162, 131, 233, 151, 156, 34, 44, 34, 115, 99, 101, 110, 97, 114, 105, 111, 84, 121, 112, 101, 34, 58, 50, 44, 34, 105, 100, 34, 58, 51, 48, 125 I/flutter (15925): 2023-10-27 09:47:58.764227 -- MqttServerConnection::_onData - Message Received Ended <<<

shamblett commented 10 months ago

The spec says -

Topic Names and Topic Filters are UTF-8 Encoded Strings; they MUST NOT encode to more than 65,535 bytes

so yes, it should. I thought it did, I'll check and get back to you.

shamblett commented 10 months ago

Yep, as I thought it does treat topic names as UTF8 encoded MQTT Strings, could you please post the Chinese topic name you are having trouble with?

neardreams commented 10 months ago

Yep, as I thought it does treat topic names as UTF8 encoded MQTT Strings, could you please post the Chinese topic name you are having trouble with?

smartDevices/房間1

shamblett commented 10 months ago

This was a bug, should be fixed now, package updated and re published at version 4.0.3

neardreams commented 10 months ago

It works, thanks!