Flutter : mqtt topic can only be english?

Viewed 23

For my Flutter project, I am using mqtt_client: ^9.7.2.

I want to subscribe & publish to a Korean topic and send/receive Korean payloads.

When I subscribe and publish to an English topic, like "test/hi", the payload decodes well using utf8.

However, if I try to subscribe to Korean topics, then it doesn't work.

If I try subscribing to "test/안녕", then nothing happens.

What I want :

EXAMPLE::Subscribing to the test/안녕 topic
EXAMPLE::Subscription confirmed for topic test/안녕
EXAMPLE::Publishing our topic
EXAMPLE::Published notification:: topic is test/안녕, with Qos MqttQos.exactlyOnce
EXAMPLE::Change notification:: topic is <test/안녕>, payload is <-- Hello 안녕하세요 -->

What is happening :

EXAMPLE::Subscribing to the test/안녕 topic
EXAMPLE::Publishing our topic
1 Answers

Topics should be UTF-8 strings.

From the specification:

3.3.2.1 Topic Name

The Topic Name identifies the information channel to which Payload data is published.

The Topic Name MUST be present as the first field in the PUBLISH packet Variable Header. It MUST be a UTF-8 Encoded String as defined in section 1.5.4 [MQTT-3.3.2-1].


3.8.3 SUBSCRIBE Payload

The Payload of a SUBSCRIBE packet contains a list of Topic Filters indicating the Topics to which the Client wants to subscribe. The Topic Filters MUST be a UTF-8 Encoded String [MQTT-3.8.3-1]. Each Topic Filter is followed by a Subscription Options byte.

So as long as it's valid it should work.

Related