🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Core2 MQTT fails to subscribe on SSL=True

    Core 2
    mqtt hivemq
    3
    9
    8.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      alexanders
      last edited by

      Hello everyone

      I have trouble with connecting my Core2 to HiveMQ using MQTT.

      What works well so far:

      • Connecting to a public MQTT broker (hivemq or mosquitto) with no auth (and no SSL) works perfectly fine.
      • Connecting to my private cloud broker works and I can send messages (from core2 to hivemq) when using the 'execute code' block.

      What does not work and drives me kind of crazy is that I don't receive any messages on the topics I subscribed to -- when being connected to the private cloud instance using SSL.

      Any hints on what is wrong are greatly appreciated :)

      Cheers, Alex

      0_1651312904171_Screenshot 2022-04-30 120111.png

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        Well, according to that image, you are missing the SSL codes, keys and certificates.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 1
        • felmueF
          felmue
          last edited by

          Hello @alexanders

          it looks like the generated micropython code is missing the statement to actually subscribe. I have to add something like below, in an Execute Code block, just before the mqtt start block to make the subscription work:

          m5mqtt.subscribe(str('kesabi'), fun_kesabi_)
          

          Thanks
          Felix

          GPIO translation table M5Stack / M5Core2
          Information about various M5Stack products.
          Code examples

          1 Reply Last reply Reply Quote 1
          • felmueF
            felmue
            last edited by

            Hello @ajb2k3

            afaik, the client keyFile and certFile are optional and only required if the MQTT broker is setup to verify the MQTT client. Or am I missing something?

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • ajb2k3A
              ajb2k3
              last edited by

              @felmue
              If you check out the Execute Code block the params are different.
              For some reason there is an oddity with security lately that if SSL is set to true in MicroPython the the files are required.

              Also the main program functions need to be run in a loop placed after the MQTT Start block.

              UIFlow, so easy an adult can learn it!
              If I don't know it, be patient!
              I've ether not learned it or am too drunk to remember it!
              Author of the WIP UIFlow Handbook!
              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

              1 Reply Last reply Reply Quote 2
              • felmueF
                felmue
                last edited by

                Hello @ajb2k3

                ah, ok, thank you for the information. I was not aware of that.

                Thanks
                Felix

                GPIO translation table M5Stack / M5Core2
                Information about various M5Stack products.
                Code examples

                ajb2k3A 1 Reply Last reply Reply Quote 1
                • ajb2k3A
                  ajb2k3 @felmue
                  last edited by

                  @felmue said in Core2 MQTT fails to subscribe on SSL=True:

                  Hello @ajb2k3

                  ah, ok, thank you for the information. I was not aware of that.

                  Thanks
                  Felix

                  No worries, it's not a well know feature.

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                  1 Reply Last reply Reply Quote 0
                  • A
                    alexanders
                    last edited by

                    Thanks a lot @ajb2k3 and @felmue for your swift responses! Good point with the subscribe statement -- and thanks for pointing out that I need to set keys and certs, I wasn't aware of that.

                    I'm sure your answers will help others, too :)

                    Cheers, Alex

                    ajb2k3A 1 Reply Last reply Reply Quote 0
                    • ajb2k3A
                      ajb2k3 @alexanders
                      last edited by

                      @alexanders thanks to you question, I have now added a paragraph about this to my book which will hopefully get an update by the end of the month!

                      UIFlow, so easy an adult can learn it!
                      If I don't know it, be patient!
                      I've ether not learned it or am too drunk to remember it!
                      Author of the WIP UIFlow Handbook!
                      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post