Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Connect CocoaMQTT connection with HiveMQ, says noAuthrized #589

Open
gurpalrajput opened this issue May 8, 2024 · 1 comment
Open
Labels

Comments

@gurpalrajput
Copy link

gurpalrajput commented May 8, 2024

Hie, I am trying to connect CocoaMQTT With HiveMQ, with correct credentials, I had verified them too, but in acknoledgement it says NotAuthrized, below is code I am trying.

Note:- Two way ssl is also working had verified.

    ///Connection Building
func buildMQTTConnection() {
    ///MQTT 5.0
    let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier)

// let mqtt5 = CocoaMQTT5(clientID: clientID, host: "broker.hivemq.com", port: 1883)
///8dbc6815c7824b0482d7ae0439514faa.s1.eu.hivemq.cloud
mqtt5 = CocoaMQTT5(clientID: clientID, host: "8dbc6815c7824b0482d7ae0439514faa.s1.eu.hivemq.cloud", port: 8883)
///
let connectProperties = MqttConnectProperties()
connectProperties.topicAliasMaximum = 0
connectProperties.sessionExpiryInterval = 0
connectProperties.receiveMaximum = 100
connectProperties.maximumPacketSize = 500
mqtt5?.connectProperties = connectProperties
mqtt5?.logLevel = .error

    /// SSL Configuration
    let clientCertArray = getClientCertFromP12File(certName: "certificate", certPassword: "gurpal")
    var sslSettings: [String: NSObject] = [:]
    sslSettings[kCFStreamSSLCertificates as String] = clientCertArray
    mqtt5?.allowUntrustCACertificate = true
    mqtt5?.enableSSL = true
    mqtt5?.sslSettings = sslSettings
    
    
    mqtt5?.username = "gurpalrajput2505"
    mqtt5?.password = "Gurpalrajput25"
    
 
   
    mqtt5?.willMessage = CocoaMQTT5Message(topic: "/will", string: "dieout")
    mqtt5?.delegate = self
    mqtt5?.keepAlive = 60

    
}

CocoaMQTT Failed to authenticate with HiveMQ, I Am using 5.0 version for CocoaMQTT.
Any solution.

@JaylinYu
Copy link
Member

debug tls layer from your hivemq.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants