MQTT with SSL gives error "OSError: -4480"



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


  • Pybytes Beta

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



  • @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?


  • Pybytes Beta

    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


  • Pybytes Beta

    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.


  • Pybytes Beta

    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.


  • Pybytes Beta

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

  • Pybytes Beta

    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
    

Log in to reply
 

Pycom on Twitter