Code Monkey home page Code Monkey logo

Comments (4)

werbenhu avatar werbenhu commented on June 11, 2024 1

@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.

werbenhu avatar werbenhu commented on June 11, 2024

我用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.

werbenhu avatar werbenhu commented on June 11, 2024

@mefly2012 Has there been any progress on this issue? Can it be closed now?

from server.

mefly2012 avatar mefly2012 commented on June 11, 2024

谢谢你的讲解,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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.