Comments (4)
@mefly2012 我用mosquitto作为broker也同样存在这个问题,我看了paho client_test.py的代码:
nosubscribe_topics = ("test/nosubscribe",)
//...
def test_subscribe_failure(self):
# Subscribe failure. A new feature of MQTT 3.1.1 is the ability to send back negative reponses to subscribe
# requests. One way of doing this is to subscribe to a topic which is not allowed to be subscribed to.
print("Subscribe failure test starting")
succeeded = True
try:
callback.clear()
aclient.connect(host=host, port=port, keepalive=60)
print('topic:', nosubscribe_topics[0])
aclient.subscribe([nosubscribe_topics[0]], [2])
time.sleep(.2)
# subscribeds is a list of (msgid, [qos])
assert callback.subscribeds[0][1][0] == 0x80, "return code should be 0x80 %s" % callback.subscribeds
except:
traceback.print_exc()
succeeded = False
print("Subscribe failure test", "succeeded" if succeeded else "failed")
self.assertEqual(succeeded, True)
return succeeded
意思这个主题test/nosubscribe在broker要设置成不被允许订阅的主题时,SUBACK包里面的 code应该返回0x80表示订阅失败。
Allowed return codes:
0x00 - Success - Maximum QoS 0
0x01 - Success - Maximum QoS 1
0x02 - Success - Maximum QoS 2
0x80 - Failure
你可以使用ACL限制客户端订阅test/nosubscribe这个主题应该就能通过测试用例了。
I encountered the same issue when using Mosquitto as a broker.I examined the code in the paho client_test.py file.
When the topic "test/nosubscribe" is set on the broker to disallow subscription, the code in the SUBACK packet should return 0x80 to indicate a subscription failure.
You can use ACL to restrict client subscription to the topic "test/nosubscribe," and this should pass the test case.
from server.
我用paho.mqtt.testing测试了,这个问题确实存在,我看看是哪里出问题了。
I have tested it using paho.mqtt.testing, and indeed, there is an issue. I'll take a look to see where the problem is.
from server.
@mefly2012 Has there been any progress on this issue? Can it be closed now?
from server.
谢谢你的讲解,auth.yaml配置文件如下,即可跑完所有用例。
这里这个auth控制一定要填东西,ip地址的模糊匹配似乎不能填*:,所以搞个10.
- remote: 10.*:*
allow: true
acl:
#0 = deny, 1 = read only, 2 = write only, 3 = read and write
- filters:
'test/nosubscribe': 0```
from server.
Related Issues (20)
- how to override payload when do message inceptor?
- Got nil exception when inceptor publish HOT 4
- Can not get onPublish called after set Inline Client HOT 10
- invalid client status which loaded from storage. HOT 6
- consume very slow when Inflights to many HOT 5
- Packet encoding optimization HOT 1
- Data race in buffer with v2.4.3 HOT 4
- Client unsubscribe topic have problem HOT 1
- Version is "2.4.1" while the package version is v2.4.3 HOT 2
- message does not save at session when client is disconnect HOT 21
- OnACLCheck BUG HOT 11
- How to enable storage simplify HOT 16
- How to disable log HOT 1
- How to allow specific username to read/write on a specific topic, and denied enything else? HOT 1
- After enabled badger, the vlog file up to 700M one day and 4GB one week HOT 9
- Race condition when running the redis example HOT 4
- 遍历Clients时如何判断当前Client是否为Disconected状态 HOT 3
- 作者您好,请帮忙关注一下这个问题 HOT 3
- Hi, what is the simplest way to make messages can be restored when server cut off? HOT 5
- [badgerdb] vlog growing unbounded - consider adding GC and exposing options HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from server.