Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to control re-subscribe functionality. #665

Merged

Conversation

redboltz
Copy link
Contributor

@redboltz redboltz commented Aug 7, 2017

This pull request implements a option resubscribe for controlling re-subscribe.
The default value of resubscribe is true. It doesn't break current behavior.
It will fix #664 partially. Partially means, if suback has error payload, then re-subscribe topics should be removed. It is a different issue.

@codecov
Copy link

codecov bot commented Aug 7, 2017

Codecov Report

Merging #665 into master will increase coverage by <.01%.
The diff coverage is 95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #665      +/-   ##
==========================================
+ Coverage   92.66%   92.66%   +<.01%     
==========================================
  Files           8        8              
  Lines         668      682      +14     
  Branches      161      167       +6     
==========================================
+ Hits          619      632      +13     
- Misses         49       50       +1
Impacted Files Coverage Δ
lib/client.js 96.17% <95%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 862cb41...f6d12f0. Read the comment docs.

@mcollina
Copy link
Member

mcollina commented Aug 7, 2017

Can you also add a fix for the other issue? There seem to be some new lines that are not covered by unit tests, would you mind adding those too?

Thanks!

@redboltz
Copy link
Contributor Author

redboltz commented Aug 7, 2017

Can you also add a fix for the other issue? There seem to be some new lines that are not covered by unit tests, would you mind adding those too?

Does the other issue mean treat well with suback error? It's OK. I'm not sure the coverage will be satisfied if I add the fix. Anyway I will do.

In order to add the fix, I need to know how do I know suback error code.
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718068
suback's payload has two information. One is QoS, the other is success/fail bit.

And I found packet.granted[0] is the raw payload. Can I use this?
(packet.payload is null)

@mcollina
Copy link
Member

mcollina commented Aug 7, 2017

Yes it's the information you are looking for is in the granted property.

@redboltz
Copy link
Contributor Author

redboltz commented Aug 7, 2017

@mcollina , thanks. I implemented the library code. Now I start writing tests. I think that the test server needs to return suback with failure bit 1. How can I do this? I'm studying other tests implementation. But if you give me some advice, it is very helpful.

@mcollina
Copy link
Member

mcollina commented Aug 7, 2017

You should instantiate a new server and replace the 'subscribe' event. See https://github.com/mqttjs/MQTT.js/blob/master/test/client.js#L128-L149 as an example.

@redboltz
Copy link
Contributor Author

redboltz commented Aug 8, 2017

@mcollina , thank you! I will write tests.

@redboltz
Copy link
Contributor Author

I implemented the fix for suback error case. I also implemented the test.
It seems that codecov is satisfied.

I implemented the test in abstract_client.js. I'm not sure either abstract_client.js or client.js is an appropriate location to implement the test.
I introduced port variable and I set server2 listening port to port + 49 just like the test you mentioned.

If there is a room to improve, please let me know.

@mcollina mcollina merged commit 81b4d7c into mqttjs:master Aug 18, 2017
@mcollina
Copy link
Member

Thanks, released as v2.12.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to disable re-subscribe functionality
2 participants