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

Error Domain=MQTT Code=-8 "Server has closed connection without connack." UserInfo={NSLocalizedDescription=Server has closed connection without connack.} #595

Open
vidhya11v opened this issue Jun 4, 2021 · 0 comments

Comments

@vidhya11v
Copy link

This is the code which I tried

let sessionManager = MQTTSessionManager()
sessionManager.delegate = self

    let userName = ""
    let password = ""
    
    let certificate = Bundle.main.path(forResource: "ca", ofType: "crt")

    let securityPolicy = MQTTSSLSecurityPolicy.init(pinningMode: .certificate)

    securityPolicy?.allowInvalidCertificates = true

    securityPolicy?.pinnedCertificates = [NSData.init(contentsOfFile: certificate!)!]

    securityPolicy?.validatesCertificateChain = false

    securityPolicy?.validatesDomainName = false
    
    sessionManager.connect(to: MQTT_HOST, port: Int(MQTT_PORT), tls: true, keepalive: 60, clean: true, auth: false, user: nil, pass: nil, will: false, willTopic: nil, willMsg: nil, willQos: .atMostOnce, willRetainFlag: false, withClientId: "client-1", securityPolicy: securityPolicy, certificates: [NSData.init(contentsOfFile: certificate!)!], protocolLevel: .version311, connectHandler:nil
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant