Code Monkey home page Code Monkey logo

Comments (9)

andreamazz avatar andreamazz commented on July 17, 2024

If this can help, you can test the ssl connection using the test endpoint provided by Mosquitto:

mqttClient = CocoaMQTT(clientId: "clientid", host: "test.mosquitto.org", port: 8883)
mqttClient?.secureMQTT = true
mqttClient?.username = "user"
mqttClient?.password = "password"
mqttClient?.keepAlive = 90
mqttClient?.delegate = self
mqttClient?.connect()

You'll need to add this cert to your keychain.

It's also worth noting that RabbitMQ enforces the use of TLSv1.2. I had to change the dictionary provided to the startTLS function to include these two options, sadly to no avail:

GCDAsyncSocketSSLProtocolVersionMin: 8, 
GCDAsyncSocketSSLProtocolVersionMax: 8

from cocoamqtt.

andreamazz avatar andreamazz commented on July 17, 2024

After some further digging, looks like that the SSL connection is correctly established, our backend closes the connection with this error:

MQTT protocol error connect_expected for connection 

Without SSL the connection works flawlessly.

from cocoamqtt.

andreamazz avatar andreamazz commented on July 17, 2024

Ok, figured it out. It's a timing issue.
I was subscribing in a completion block triggered by the didConnect delegate. This is fine when done in plain MQTT, but not when using SSL, as you can see here:
https://github.com/emqtt/CocoaMQTT/blob/master/Source/CocoaMQTT.swift#L303
the delegate is called right away, but it should be called once the secure channel is created, in the socketDidSecure delegate method.

from cocoamqtt.

CrazyWisdom avatar CrazyWisdom commented on July 17, 2024

@andreamazz thanks

from cocoamqtt.

andreamazz avatar andreamazz commented on July 17, 2024

Thanks for merging.
Are you planning a new release any time soon? I would greatly appreciate that (I'm using this as a dependency for another podspec, so I need to reference a version).

from cocoamqtt.

CrazyWisdom avatar CrazyWisdom commented on July 17, 2024

@andreamazz Yes, tomorrow or the day after tomorrow

from cocoamqtt.

andreamazz avatar andreamazz commented on July 17, 2024

Thanks.

from cocoamqtt.

CrazyWisdom avatar CrazyWisdom commented on July 17, 2024

@andreamazz , v1.0.7 released.

from cocoamqtt.

andreamazz avatar andreamazz commented on July 17, 2024

Great, thank you 👍

from cocoamqtt.

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.