Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    MQTT with SSL gives error "OSError: -4480"

    Scheduled Pinned Locked Moved MicroPython
    8 Posts 2 Posters 70 Views 2 Watching
    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.
    • L Offline
      Louis Henn
      last edited by

      Hi everyone.

      I'm having quite a bit of trouble connecting to a HiveMQ server on my SiPy device. I did manage to connect to the public broker for a test, and could subscribe and publish. Now I have a cluster on HiveMQ and I have been having trouble connecting. Have worked through most of the problems, but I can't seem to get past this one.

      When the connect() function is called, line 69 of mqtt.py:
      "self.sock = ussl.wrap_socket(self.sock, **self.ssl_params)"
      raises the error:
      "OSError: -4480"
      I have tried changing parameters, and even entered the certificate manually in mqtt.py, but I keep receiving the same error.

      I have searched online but there doesn't seem to be any record of this error, so I am not sure how to proceed. Does anyone know what this error means, and perhaps what I can do to fix it?

      Thanks, Louis.

      1 Reply Last reply Reply Quote 1
      • B Offline
        BetterAuto Pybytes Beta
        last edited by

        I too am seeing a -4480 error when using the Google IoT library. I used their main.py unmodified, so I don't think it's me.

        The underlying cause seems to have something to do with the random number generator. See also this.

        What firmware are you on? I'm on 1.20.2.r4 with the Google library frozen in. Next, I will try the standard firmware (nothing frozen in) and then I will try downgrading to an older firmware.

        Traceback (most recent call last):
          File "main.py", line 52, in <module>
          File "google_iot_core.py", line 93, in __init__
          File "google_iot_core.py", line 63, in _create_google_jwt
        ValueError: Invalid Private Key, error code: -4480
        
        1 Reply Last reply Reply Quote 0
        • B Offline
          BetterAuto Pybytes Beta
          last edited by

          No good on standard firmware (nothing frozen, 1.20.2.r4), or 1.20.2.r3, or 1.20.1, or 1.20.0.rc11. I am next going to try using my private key on my desktop or a Raspberry Pi or something.

          Oh and forgot to mention, the random generator seems to be working fine.

          >>> from machine import rng
          >>> rng()
          3738696
          >>>
          
          1 Reply Last reply Reply Quote 0
          • B Offline
            BetterAuto Pybytes Beta
            last edited by

            I determined the error has to do with ucrypto.generate_rsa_signature() and that function actually is working on 1.20.0.rc11, contradicting what I'd said above. Not sure why it didn't work before. This function seems to be broken on later firmwares. I'm going to load newer ones until I find where it broke.

            1 Reply Last reply Reply Quote 0
            • B Offline
              BetterAuto Pybytes Beta
              last edited by

              So... the problem (for me anyway) lies in some change made between 1.20.0.rc13 and 1.20.1. Between those versions, generate_rsa_signature() broke, according to my testing.

              Try 1.20.0.rc13 and see if it works. It can be found in the flasher under legacy.

              1 Reply Last reply Reply Quote 0
              • B Offline
                BetterAuto Pybytes Beta
                last edited by BetterAuto

                I have opened a bug report. The workaround is to use firmware 1.20.0.rc13.
                https://github.com/pycom/pycom-micropython-sigfox/issues/545

                L 1 Reply Last reply Reply Quote 1
                • L Offline
                  Louis Henn @BetterAuto
                  last edited by

                  @BetterAuto Thanks. Downgrading did the trick. Although, 1.20.0.rc13 did not like connecting to the wlan network. Version 1.19.0.b4 worked. Thanks for reporting the bug.

                  Now the only problem I'm getting is a MQTTException: 5. Seems like this means the server refuses the connection since my device is not authorised. Seems like this usually happens with an incorrect username/password, but I know mine is correct. I don't suppose anyone knows what this problem could be?

                  B 1 Reply Last reply Reply Quote 0
                  • B Offline
                    BetterAuto Pybytes Beta @Louis Henn
                    last edited by

                    @Louis-Henn said in MQTT with SSL gives error "OSError: -4480":

                    Now the only problem I'm getting is a MQTTException: 5. Seems like this means the server refuses the connection since my device is not authorised. Seems like this usually happens with an incorrect username/password, but I know mine is correct. I don't suppose anyone knows what this problem could be?

                    I am fairly certain that is what it means. Double-check your password with a mosquitto client or some MQTT tester. Also, try against an MQTT test server which has no authentication.

                    1 Reply Last reply Reply Quote 0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • 1 / 1
                    • First post
                      Last post

                    Pycom on Twitter

                    Pycom