valid utf8 in mqtt

337 views
Skip to first unread message

kushal bhattacharya

unread,
Nov 3, 2016, 8:29:26 AM11/3/16
to MQTT
hii,
Could you guys please tell me what are the valid UTF-8 characters allowed in mqtt.Actually i have built an mqtt client and now my task is to build a mqtt broker,Now am stuck in parsing CONNECT PACKET  in mqtt broker.I am clueless on the return code' The Client identifier is correct UTF-8 but not allowed by the Server'.Could you please  help me in designing the way to parse packet format from client to server in general and in this case how to build a parser mechamism.
Thanks,
Kushal Bhattacharya

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

unread,
Nov 3, 2016, 11:01:50 AM11/3/16
to mq...@googlegroups.com
If your question is, when should the broker return the return code 0x02, then the answer is, it is completely dependent on the broker implementation. For example, you may accept only those identifiers that are MAC addresses, zip codes, vehicle license plater number, employee ID, etc.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

kushal bhattacharya

unread,
Nov 4, 2016, 1:26:07 AM11/4/16
to MQTT
actually am building a general mqtt broker now.Am totally confused about how to check for all the return codes .Could you give the scenarios where i can catch those return codes,What i mean to say is in which error case do i return those return codes.It would be really nice of you if you could elaborate it.
Thanks,
Kushal Bhttacharya

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

unread,
Nov 4, 2016, 3:15:50 AM11/4/16
to mq...@googlegroups.com

At least for the CONNECT message received by the broker, the return code is set by the broker (for the subsequent CONNACK message); not checked.  Are you asking how/when to set this return code?

Pardon brevity, typos and grammar mistakes. Sent from phone.


--

kushal bhattacharya

unread,
Nov 4, 2016, 4:13:24 AM11/4/16
to MQTT
thts the exact thing i am asking sorry i was twisting this out

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

unread,
Nov 4, 2016, 4:21:10 AM11/4/16
to mq...@googlegroups.com

Ok. The following could be steps:

1. Parse CONNECT message to extract client inditifier - clientId
2. Invoke a function validateClientId (clientId )
3. The implementation of the function validateClientId() returns Boolean value.
4. If validateClientId() is False, set rc as 0x02 for CONNACK message.
5. Write CONNACK message.

Pardon brevity, typos and grammar mistakes. Sent from phone.

On 4 Nov 2016 13:43, "kushal bhattacharya" <bhattachar...@gmail.com> wrote:
thts the exact thing i am asking sorry i was twisting this out

--

kushal bhattacharya

unread,
Nov 4, 2016, 4:30:29 AM11/4/16
to MQTT
but how do i detect those particular error codes in the function i mean how do i catch those errors

kushal bhattacharya

unread,
Nov 4, 2016, 4:31:37 AM11/4/16
to MQTT
i have built a parse function but i can't catch all the error scenarios here.I am confused in which  scenarios do i return the respective error codes .

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

unread,
Nov 4, 2016, 4:46:43 AM11/4/16
to mq...@googlegroups.com
Ok. Going by the return codes as listed here [1], the possible interpretation are:

0x01 - Parse for protocol level in the CONNECT message. The level will be byte 7 in the variable header of the CONNECT message. Test for its validity based on broker's implementation of MQTT. [2] 
0x02 - Parse the CONNECT message for the client identifier and test for validity against business cases, etc.
0x03 - Probably, when something other than network is broke (disk full, hartal ?)
0x04 - Parse for user name and password in CONNECT message. Validate the same against a username and password repo.
0x05 - Parse for client identifier and validate against a Access Control List.



On Fri, Nov 4, 2016 at 2:01 PM, kushal bhattacharya <bhattachar...@gmail.com> wrote:
i have built a parse function but i can't catch all the error scenarios here.I am confused in which  scenarios do i return the respective error codes .

--

kushal bhattacharya

unread,
Nov 4, 2016, 4:53:36 AM11/4/16
to MQTT
hi,
I am confused about the 3rd case could you please elaorate it a bit actually i have slightly covered the other cases nearly the way you listed above but i am confused about the 3rd case

Nicholas O'Leary

unread,
Nov 4, 2016, 5:49:13 AM11/4/16
to mq...@googlegroups.com
Hi,

Return code 0x03 is there if you need to tell the client the server is not available to accept the connection. Why that may happen will be down to what your implementation needs. If you don't have a need for it, then you don't need to return it.

Nick



On 4 November 2016 at 08:53, kushal bhattacharya <bhattachar...@gmail.com> wrote:
hi,
I am confused about the 3rd case could you please elaorate it a bit actually i have slightly covered the other cases nearly the way you listed above but i am confused about the 3rd case

--

kushal bhattacharya

unread,
Nov 4, 2016, 6:52:40 AM11/4/16
to MQTT
hi,
actually i don't know know until now in what scenarios do i specifically need this.Sould you be more specific with some instances .Sorry actually am confused about this .Thanks,
Kushal Bhattacharya

Paul Fremantle

unread,
Nov 4, 2016, 7:26:10 AM11/4/16
to mq...@googlegroups.com
Kushal

Have you read the specification? It is reasonably clear.

Paul

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.



--
Paul Fremantle
Doctoral Researcher, University of Portsmouth, School of Computing
Visiting Scientist, Institute of the Architecture of Application Systems, Stuttgart
Visiting Lecturer, Software Engineering Programme, Oxford University
Co-Founder, WSO2
Apache Member and Committer
twitter: pzfreo / skype: paulfremantle / blog: http://pzf.fremantle.org

kushal bhattacharya

unread,
Nov 4, 2016, 7:33:38 AM11/4/16
to MQTT
hi,
Yes i have thoroughly rea the specification of the mqtt.It only states that the broker will send this return code only if network connection is established but the mqtt server is not available.What exactly is meant by that? I mean in which basis do i check for the above to be true .I just want to know some instances so that it becomes clea to me

Nicholas O'Leary

unread,
Nov 4, 2016, 7:37:38 AM11/4/16
to mq...@googlegroups.com
kushal, this return code is a catch-all to allow the server to reject a connection. It is for he broker to decide when it needs to take advantage of this return code - it will depend entirely on the broker's implementation.

There is not a simple binary true/false test it maps to.

Some examples have already been given - maybe the broken finds it has lost access to its storage so cannot service the connection. Maybe an administrator has told the broker to temporarily reject new connections... The list of possible reasons it endless - it is up to the broker implementation to decide when it wants to use it.

Nick



On 4 November 2016 at 11:33, kushal bhattacharya <bhattachar...@gmail.com> wrote:
hi,
Yes i have thoroughly rea the specification of the mqtt.It only states that the broker will send this return code only if network connection is established but the mqtt server is not available.What exactly is meant by that? I mean in which basis do i check for the above to be true .I just want to know some instances so that it becomes clea to me

--

kushal bhattacharya

unread,
Nov 4, 2016, 7:54:29 AM11/4/16
to MQTT
thanx a lot nick actually am building mqtt broker all by myself  .Previously i have built mqtt client and integrated it with paho client with shared libraries.Now the thing is i am trying to make a communication between my mqtt client and broker so i have lots of confusions built in my mind.The examples which you gave to me have me somewhat clear :).Now  actually i have to communicate with my boss regarding this implementation and accordingly implment against this return code.Thanks for the elaboration.

Roger Light

unread,
Nov 4, 2016, 11:44:38 AM11/4/16
to MQTT
On Fri, Nov 4, 2016 at 11:37 AM, Nicholas O'Leary <nick....@gmail.com> wrote:
> It is for he broker to decide when it needs to take advantage of
> this return code - it will depend entirely on the broker's implementation.

For example, current versions of mosquitto will never return this code.

Cheers,

Roger
Reply all
Reply to author
Forward
0 new messages