Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Add option 'qos2Puback' -easy merge #642

Merged
merged 5 commits into from May 19, 2017

Conversation

btsimonh
Copy link
Contributor

Add option 'qos2Puback' - if set to true, will modify published qos 2 messages to qos 1 before processing.
This results in the messages getting a puback, which fools mqtt.js into not getting stuck when sending qos 2 to mosca.
It's an option because the spec does not allow for this? Probably will not suit all clients, but better than mqtt.js dying; a patch over the issue until mosca can get true QOS-2 or QOS-2 pseudo-processing.

This PR replaces the previous for ease of merging and understanding the changes.

…ges to QOS-1, resulting in a puback message.

Prevents mqtt.js keeping qos-2 messages forever if incorrectly configured.
@@ -19,6 +19,7 @@ var moscaSetting = {
{ type: "https", port: 3001, bundle: true, credentials: { keyPath: SECURE_KEY, certPath: SECURE_CERT } }
],
stats: false,
qos2Puback: false, // can set to true if using a client which will eat puback for QOS 2; e.g. mqtt.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking more about this, and I think this behavior should be a bit more customizable. How about adding it as a string with two options:'dropToQoS1','ignore'and'disconnect'? Maybe we can call it onQoS2publish`?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an example of close of the connection is just above, so it's not going to take much serious thought :).
Are we worried about string comparison in such a well-called area of code?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not worry about it, it should not be a hot path: QoS 2 is not really supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I move the 'if' so it checks the QOS before anything else anyway. It's only here as an option to protect stupids like me who set mqtt.js to QoS2 :). (well node-red does default to QoS2 for mqtt subscription; fooled me).

…nitially 'noack', and can optionally be 'disconnect' or 'dropToQoS1'

'disconnect' will cause a client disconnect on receipt of a QoS2 message.
'dropToQoS1' will puback the message, allowing mqtt.js to work; just not at QoS2 service level.
@btsimonh
Copy link
Contributor Author

take a look. not tested, but tests added (maybe travis will tell us if I screwed it up :) ).

@mcollina
Copy link
Collaborator

@btsimonh
Copy link
Contributor Author

error in test - sent QoS1 and expected it to disconnect! fixed now hopefully; give travis another 10 minutes.
p.s. tests fail on windows? I have to move server tests above persistence tests to see my results - is it because I don't have the backends?

@mcollina
Copy link
Collaborator

@btsimonh
Copy link
Contributor Author

for my future reference:
node .\node_modules\mocha\bin\mocha --recursive --bail --reporter spec test/server.js
still failing (any locally) .... bear with me.

@btsimonh
Copy link
Contributor Author

not failing locally anymore. Love travis; had actually got the code all in the wrong place. Should be good to go now.

@btsimonh
Copy link
Contributor Author

all good now, only node4 failing at redis.

@mcollina mcollina merged commit 19b6d25 into moscajs:master May 19, 2017
@btsimonh btsimonh deleted the btsimonh-qos-2-mk2 branch May 19, 2017 17:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants